# GeneralMiniMaxApproximation - Dividing out the zero

MiniMaxApproximation is used to generate minimax approximations. I'm interested in the "dividing out the zero" trick.

The documentation discusses a nice example. Suppose we want to construct a minimax approximation of $\cos (x)$ on $x \in [1,2]$. Since the function MiniMaxApproximation uses the relative error the function being approximated can not have a zero in the interval of question ($\cos(\pi/2)=0$). However "it is still possible to deal with such functions, but the zero must be divided out of the function and then multiplied back into the rational function". So instead of approximating $\cos(x)$ we approximate

$$\frac{\cos(x)}{x-\frac{\pi}{2}}$$

The mathematica code to do this is

MiniMaxApproximation[Cos[x]/(x - \[Pi]/2), {x, {1, 2}, 2, 4}][[2, 1]]


as in the documentation. I was wondering if there is a similar trick that can be used with GeneralMiniMaxApproximation. This function approximates parametrically defined functions of the form $(x(t), y(t))$. Note that $\cos (x)$ on $x \in [1,2]$ can be defined parametrically as $(\arccos(t),t)$ where $t \in (\cos(1),\cos(2))$. So the mathematica code to approximate this function looks like

GeneralMiniMaxApproximation[{ArcCos[t], t}, {t, {Cos[1], Cos[2]}, 3,
2}, x]


However it fails because of the zero occuring in the interval of approximation. I was wondering if there is a way to extend the above trick so that it will work with GeneralMiniMaxApproximation??

I would like to stick with using the relative error as opposed to the absolute error.

My attempt:

I thought maybe a shift in the y-axis would do the trick. ie. approximate $\cos (x) + 1$ on $x \in [1,2]$ (which has no zero in this interval). We can subtract the one after. This is equivalent to approximating the parametrically defined function $(\arccos(t-1),t)$ where $t \in (\cos(1)+1,\cos(2)+1)$. The mathematica code is then given by,

GeneralMiniMaxApproximation[ {ArcCos[t - 1], t}, {t, {Cos[1] + 1, Cos[2] + 1}, 2, 3}, x]


But this does not work for some reason. It complains the weight function $t$ could be disappearing. But this is not the case since $t$ is positive on $(\cos(1)+1,\cos(2)+1)$. Any ideas why this doesn't work?

• Try GeneralMiniMaxApproximation[{ArcCos[t - 1], t}, {t, {Cos[2] + 1, Cos[1] + 1}, 2, 3}, x] Nov 8, 2012 at 5:39

Well, since I rarely grab a chance to post an answer in this site I decide to enlarge my comment above XD.

In general, the error you encountered is nothing to do with your trick for getting around zero, it's just because $cos(t)$ in $[1, 2]$ is monotone decreasing:

I.e. Cos[2] is the minimum and Cos[1] is the maximum, while the syntax for GeneralMiniMaxApproximation mentioned in the introduction of Function Approximations Package is:

GeneralMiniMaxApproximation[{Subscript[f, x],Subscript[f, y]},{t,{Subscript[t, min],Subscript[t, max]},m,k},x]

So your trick will work if you exchange the endpoints:

<< FunctionApproximations
app = GeneralMiniMaxApproximation[{ArcCos[t - 1], t},
{t, {Cos[2] + 1, Cos[1] + 1}, 2, 3}, x];
Plot[app[[2, 1]] - 1 - Cos[x], {x, 1, 2}, PlotRange -> All]


However, there's still a mystery leaved: after some trial I noticed that the order of the endpoints is not necessary for Plot ParametricPlot PolarPlot at all, and in fact the description for the syntax in the page for GeneralMiniMaxApproximation doesn't mention the order, too:

GeneralMiniMaxApproximation[{Subscript[f, x], Subscript[f, y]}, {t, {Subscript[t, 0], Subscript[t, 1]}, m, n}, x]

I'm not sure in which case the order is vital… personally I suggest the order should always be paid attention to, since the help doesn't explicitly mention that the interval in Plot etc. can be reversed. Looking forward to an explain from someone more knowledgeable!

• Yes thats what threw me, ParametricPlot` did not seem to care of the order. thanks, for pointing this out, i was scratching my head for hours wondering why this doesn't work!! Hopefully I too can follow in your footsteps soon and help other people out. Nov 8, 2012 at 7:03
• @aukie Hopefully I too can follow in your footsteps soon and get one or two Nice Question bronze XD. Nov 8, 2012 at 7:28