Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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}$... – J. M. Nov 25 '12 at 9:45
$\dfrac{x\lvert\cos\theta\rvert}{\sqrt{1+x^2}}$ seems to be pretty good to me. – Rahul Nov 25 '12 at 11:01
Looks more like a math question. – Jens Nov 25 '12 at 21:40
up vote 4 down vote accepted

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


share|improve this answer
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

share|improve this answer
I've updated the question. I think this is now much easier to understand. – m0nhawk Nov 25 '12 at 9:10
One might also consider looking at the relative error in addition to the absolute error... – J. M. Nov 25 '12 at 9:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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