1
$\begingroup$

I have an exact equation:

\begin{equation} a = \sqrt{1 + x^2 - \sqrt{(1 + x^2)^2 - 2 x^2 \cos^2\theta}}\tag{1} \end{equation}

and its approximation:

\begin{equation} a = \dfrac{x \cos^2\theta}{\sqrt{1 + x^2}}\tag{2} \end{equation}

I'm doing most theoretical calculations using equation $(2)$ and to check the outcomes I'm doing numerical calculations of $(1)$ in Mathematica.

For example, finding $\left.\frac{da}{dx}\right|_{x = 0}$ dividing by $\left.\frac{da}{d\theta}\right|_{\theta = 0}$ and integrating:

\begin{equation} \int\limits_{0}^{A}\frac{\left.\frac{da}{dx}\right|_{\theta = 0}}{\left.\frac{da}{d\theta}\right|_{\theta = 0}}dx \end{equation}

And I want to check that this (or any other) procedure doesn't differ much from the same for precise and approximate function.

How can I verify that the use of the approximate formula doesn't make the calculations inaccurate?

$\endgroup$
3
  • $\begingroup$ A slightly more accurate approximation might be had by using $\dfrac{x\cos\theta}{\sqrt{1+x^2}}$ $\dfrac1{1-\left(\frac{x\cos\theta}{2(1+x^2)}\right)^2}$... $\endgroup$
    – J. M.'s torpor
    Nov 25 '12 at 9:45
  • 1
    $\begingroup$ $\dfrac{x\lvert\cos\theta\rvert}{\sqrt{1+x^2}}$ seems to be pretty good to me. $\endgroup$
    – user484
    Nov 25 '12 at 11:01
  • $\begingroup$ Looks more like a math question. $\endgroup$
    – Jens
    Nov 25 '12 at 21:40
4
$\begingroup$

I don't understand how you get your approximate expression. I'd do a series expansion of your expression and check how well it approximates it :

exact2[x_, y_] = Sqrt[1 + x^2] Sqrt[1 - Sqrt[1 - 2 (y/(1 + x^2))^2]];

Simplify[exact2[x, x Cos[\[Theta]]],  Assumptions -> {x \[Element] Reals, \[Theta] \[Element] Reals}] ==  
Simplify[exact[x, \[Theta]], Assumptions -> {x \[Element] Reals, \[Theta] \[Element] Reals}]

(* True *)

appr[x_, \[Theta]_] = Simplify[Normal[Series[exact2[x, y], {y, 0, 2}]],
   Assumptions -> {x \[Element] Reals}] /. y -> (x Cos[\[Theta]]) 

(* (x Cos[\[Theta]])/Sqrt[1 + x^2] *)

You can check how well the approximation is valid for $x \cos(\theta) \approx 0$ :

RegionPlot[Abs[exact[x, \[Theta]] - appr[x, \[Theta]]] < 0.001, {x, -5, 5}, {\[Theta], -\[Pi], \[Pi]} ,
  FrameTicks -> {Automatic, {-\[Pi]/2, \[Pi]/2}}, FrameLabel -> {"x", "\[Theta]"}, PlotPoints -> 50]]

plot

$\endgroup$
1
$\begingroup$
exact[x_, \[Theta]_] := 
 Sqrt[1 + x^2 - Sqrt[(1 + x^2)^2 - 2 x^2 Cos[\[Theta]]^2]]
approximate[x_, \[Theta]_] := x Cos[\[Theta]]^2/Sqrt[1 + x^2]

I'm not sure what kind of verification you want, or what your values are, but you could make a plot to get an idea (now with relative error as @J.M suggested)

absoluteError[x_, \[Theta]_] := 
 exact[x, \[Theta]] - approximate[x, \[Theta]]
relativeError[x_, \[Theta]_] := 
 1 - approximate[x, \[Theta]]/exact[x, \[Theta]] // Abs

Plot3D[absoluteError[x, \[Theta]], {x, -0.2, 0.2}, {\[Theta], -Pi, Pi}, 
 AxesLabel -> (Style[#, 20] & /@ {"x", "\[Theta]"})]

Mathematica graphics

Plot3D[relativeError[x, \[Theta]], {x, -0.02, 0.2}, {\[Theta], -Pi, 
  Pi}, AxesLabel -> (Style[#, 20] & /@ {"x", "\[Theta]"}), 
 PlotRange -> {0., 0.2}]

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ I've updated the question. I think this is now much easier to understand. $\endgroup$
    – m0nhawk
    Nov 25 '12 at 9:10
  • 3
    $\begingroup$ One might also consider looking at the relative error in addition to the absolute error... $\endgroup$
    – J. M.'s torpor
    Nov 25 '12 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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