4
$\begingroup$

I have a very odd question. I have a complicated expression that is proportional to dx and dy. I want to drop everything that is not dx^(n) *Exp[..], dy^(n)*Exp[..], dx^(n)*dy^(n)*Exp[..]. For the sake of the argument, here is an example:

dx/(x*y) + dx^3/(9*x*y)+ dy/(x*y)+dx*Exp[x]/(x*y) + dx^3*dy^3*Exp[3*(x+y)]/(x*y)

Is there anyway how to automatize it?

The result should look like this:

dx*Exp[x]/(x*y) + dx^3*dy^3*Exp[3*(x+y)]/(x*y)
$\endgroup$
0

2 Answers 2

4
$\begingroup$
expr = dx/(x*y) + dx^3/(9*x*y) + dy/(x*y) + dx*Exp[x]/(x*y) + 
   dx^3*dy^3*Exp[3*(x + y)]/(x*y)

DeleteCases[Except[_. (dx | dy)^(_.) Exp[_]]] @ expr
 (dx E^x)/(x y) + (dx^3 dy^3 E^(3 (x + y)))/(x y)
TeXForm @ %

$$\frac{\text{dx}^3 \text{dy}^3 e^{3 (x+y)}}{x y}+\frac{\text{dx} e^x}{x y}$$

$\endgroup$
3
$\begingroup$
DeleteCases[func, Except[Alternatives[dx, dx^_, dy, dy^_] Exp[_] _]
(* returns: (dx E^x)/(x y) + (dx^3 dy^3 E^(3 (x + y)))/(x y) *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.