How to extract specific parts of an equation in MuPAD or Maple

657 views Asked by At

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

1

There are 1 answers

1
Carl Love On BEST ANSWER

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.