Alex Rivera | Logout

Extracting an expression matching a pattern from a large expression

Asked 2011-04-15T22:30:19.000
12

I have a Mathematica expression that contains a single square root, schematically

expr = a / (b + Sqrt[c]);

where a,b,c are large expressions. I would like to extract the expression under the sqrt, for instance by matching to a pattern, something like

Match[expr,Sqrt[x_]] // should return c

Is there an easy way to do this?

Edit
Report

1 Answer

5

I await a few examples, but in the meantime, try:

Cases[expr, x_^(1/2 | -1/2) :> x, Infinity]

The standard internal form for Sqrt(x) is Power[x, 1/2].

answered 2011-04-15T22:45:12.660

Your Answer