3
$\begingroup$

Is there a way in Mathematica to simplify expressions based on inexact or "relative" assumptions such as $x<<y$ 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<<L$. 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<<L$ 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?

$\endgroup$
5
  • 1
    $\begingroup$ Interesting. Can Limits be used and then simplified? $\endgroup$
    – MathX
    Apr 21 at 15:00
  • 1
    $\begingroup$ @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[θ]*) $\endgroup$
    – ydd
    Apr 21 at 15:33
  • $\begingroup$ Looks like an answer to me, it's exactly what he wanted. I think people will benefit if you post it. $\endgroup$
    – MathX
    Apr 21 at 16:21
  • $\begingroup$ 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. $\endgroup$ Apr 21 at 17:12
  • $\begingroup$ Substitute d -> z L and then use Limit or Series to take the limit as z goes to zero. $\endgroup$
    – bbgodfrey
    Apr 21 at 18:09

2 Answers 2

5
$\begingroup$

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[θ] *)
$\endgroup$
3
  • 1
    $\begingroup$ Unnecessary in this case, but more generally, replace d->d1 L, do an expansion around d1=0, then substitute back d1->d/L. $\endgroup$
    – mikado
    Apr 21 at 15:51
  • $\begingroup$ @mikado, yes, that would be the general approach! $\endgroup$
    – Domen
    Apr 21 at 15:55
  • 1
    $\begingroup$ 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. $\endgroup$ Apr 22 at 13:21
3
$\begingroup$

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}}]

enter image description here

$\endgroup$

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