1

I have MuPAD and Maple and I would like to do the following with one of those softwares:

  • I have an equation containing several cosines with different amplitudes and different arguments as depictetd in the picture below in the first (blue) row.
  • I want to extract only those cosines which contain at least the argument "+at-bt" (so "+at-bt+alpha" is OK, too) - see second (blue row).
  • I want to display the summ of amplitudes of this specific cosines - see third (red) row.

The second picture shows a real example. Example Example2

Semjon Mössinger
  • 1,798
  • 3
  • 22
  • 32
  • This is doable in Maple, certainly, but before I answer how, I need to know if any of the arguments appear as, for example, `alpha + (a-b)*t`. What about `cos(b*t-a*t)`, which equals `cos(a*t-b*t)` because cosine is an even function? – Carl Love Dec 05 '13 at 15:15
  • I also need to know whether `a*t` or `b*t` will ever appear "nested" in an argument to cosine, such as `cos(1/(a*t-b*t) + alpha)`. – Carl Love Dec 05 '13 at 17:03
  • I've added a real example which is not simplified as the first example. `cos(b*t-a*t)` can occur, but `cos(1/(a*t-b*t))` will not - as depicted on the new picture above. By the way I'm working on an solution by using regular expressions. But a solution with maple will still help. – Semjon Mössinger Dec 05 '13 at 22:49

1 Answers1

2

Let's say that your long expression is named expr. Then do this

TypeTools:-AddType(
     MyCos,
     cos(satisfies(x-> x::`+` and {a*t, -b*t} subset {op(x)} or x = b*t-a*t))
): 

subex:= select(T-> T::MyCos or T::`*` and membertype(MyCos, {op(T)}), expr);

Now subex is your desired subexpression. If you want to add up the coefficients, then simply do eval(subex, cos= 1).

Note that this will not find partially factored arguments like (a-b)*t+alpha. If you need to find these, let me know.

Carl Love
  • 1,461
  • 8
  • 7
  • @Ergodicity: Your suggested edit was correct. Sorry that I didn't have the rep needed to override the rejection of your edits. – Carl Love Dec 06 '13 at 11:19