# Is there a way in Mathematica to simplify expressions based on inexact assumptions? [closed]

Is there a way in Mathematica to simplify expressions based on inexact or "relative" assumptions such as $$x< or $$x\approx y$$?

I see Simplify[expr, assum] takes an Assumption, e.g.

• Simplify[Sqrt[x^2], x>0]

• Simplify[Sqrt[x^2], Element[x, Reals]]

But these appear to require exact assumptions.

To give an applicable example, I would like

$$\sqrt{\left(\frac{d}{2}\right)^2+\left(\frac{L}{\cos{\theta}}\right)^2+dL\tan{\theta}}-\sqrt{\left(\frac{d}{2}\right)^2+\left(\frac{L}{\cos{\theta}}\right)^2-dL\tan{\theta}}$$

to simplify to

$$d\sin{\theta}$$

given $$d<. I confirmed the truth of this in another question at math.stackexchange.com. Assuming simply that $$d==0$$ does produce the desired result, but fails to consider a nuance, I think: How could one simply assume $$dL=0$$ if $$L$$ were in fact very large? A nuanced answer takes into account an expansion of the original expression using Newton's generalized binomial theorem, where $$x=\left(\frac{d}{2}\right)^2+\left(\frac{L}{\cos\theta}\right)^2$$ and $$y=\pm dL\tan\theta$$, to observe that every other term will cancel out, leaving the first-order term $$x^r=\sqrt{\left(\frac{d}{2}\right)^2+\left(\frac{L}{\cos\theta}\right)^2}$$ to be the dominant factor.

So, of course, an expression like $$d< forces one to ask, "How much smaller?", and I'm not sure how to resolve that. Would one supply a parameter, such as an estimated orders of magnitude apart? Or could an algorithm try numerically up to a certain distance, hoping to detect a non-trivial simplification?

• Interesting. Can Limits be used and then simplified? Apr 21 at 15:00
• @MathX Limit[expr, L -> Infinity] works but to get d Sin[θ] I had to also specify -Pi/2 < θ < Pi/2  lim = Limit[expr, L -> Infinity];  Simplify[lim, Assumptions -> -Pi/2 < θ < Pi/2]  (*d Sin[θ]*)
– ydd
Apr 21 at 15:33
• Looks like an answer to me, it's exactly what he wanted. I think people will benefit if you post it. Apr 21 at 16:21
• Respectfully, I'm not quite sure. As I explained in the post, simply getting the end result isn't necessarily correct. I could just as simply say, for example, "Forget Limit, forget even Simplify, just consider $d$ infinitesimal and say $d=0$." That gives the same end result but that's because it happens to work out that way in my given example. So let me try to think of an example that would not work by doing that or using Limit... My fault for not thinking of such earlier. Maybe Limit does take that into account, I'm not sure. Apr 21 at 17:12
• Substitute d -> z L and then use Limit or Series to take the limit as z goes to zero. Apr 21 at 18:09

Simply expand your expression around $$d = 0$$ with Series.

expr = -Sqrt[d^2/4 + L^2/Cos[θ]^2 - d  L Tan[θ]] + Sqrt[d^2/4 + L^2/Cos[θ]^2 + d  L  Tan[θ]]

Series[expr, {d, 0, 1}] // PowerExpand // Normal
(* d Sin[θ] *)


Or to be more precise, as suggested by @mikado (and similar to @BobHanlon's answer), consider $$d \mapsto \varepsilon L$$ for $$\varepsilon \to 0$$.

PowerExpand@Normal@Series[expr /. d -> ϵ  L, {ϵ, 0, 1}] /. ϵ -> d/L
(* d Sin[θ] *)

• Unnecessary in this case, but more generally, replace d->d1 L, do an expansion around d1=0, then substitute back d1->d/L. Apr 21 at 15:51
• @mikado, yes, that would be the general approach! Apr 21 at 15:55
• Similarly, an approximation of the form $x \approx y$ can be attacked by substituting y -> x + eps, expanding in eps, and then (optionally) substituting back eps -> y - x. Apr 22 at 13:21

Try Asymptotics and substitution d->eps L

expr = -Sqrt[d^2/4 + L^2/Cos[\[Theta]]^2 - d L Tan[\[Theta]]] +Sqrt[d^2/4 + L^2/Cos[\[Theta]]^2 + d L Tan[\[Theta]]]

res=Simplify[Asymptotic[expr /. d -> eps L, eps -> 0], L > 0] /. eps ->d/L
(*d Cos[\[Theta]] Sqrt[Sec[\[Theta]]^2] Sin[\[Theta]]*)

Plot[{res/d, Sin[\[Theta]]}, {\[Theta], -Pi, Pi}, PlotStyle -> {Blue, {Dashed, Red}}]