I have MuPAD and Maple and I would like to do the following with one of those softwares:
The second picture shows a real example.
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.