Extracting an expression matching a pattern from a large expression

后端 未结 3 642
臣服心动
臣服心动 2021-02-04 12:44

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

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

where a,b

3条回答
  •  不思量自难忘°
    2021-02-04 13:19

    Theoretically, this should work correctly:

    extractSqrt = Cases[ToBoxes@#, SqrtBox@x_ :> ToExpression@x, Infinity] &;
    
    extractSqrt[expr]
    

提交回复
热议问题