# Computing approximation of cos function

i have an assignement in which the whole point was to approximate $$\cos$$ function using 2 methods :

1. Using series expansion
2. using a more algebric method with a linear system

The teacher also defined 2 way of estimating errors in the approximation : be $$f$$ a function defined on [a,b] and $$P(x)$$ the polynom approaching $$f$$

the maximal error rate is : $$e_{max} = \max |f(x) - P(x)|$$

we also have $$e_{avg}$$ which uses integrals but she's not relevant in this part of the problem. The system is defined as follows $$\begin{eqnarray} ax_{1}^{2}+bx_{1}^{2} + c &=& \cos x_{1} \\ ax_{2}^{2}+bx_{2}^{2} + c &=& \cos x_{2} \\ ax_{3}^{2}+bx_{3}^{2} + c &=& \cos x_{3} \end{eqnarray}$$ with $$I = [0,\frac{\pi}{2}]$$ and $$x_1,x_2,x_3 \in I$$

All the questions were asked to be solved with $$x_1 = 0, x_2 = \frac{\pi}{3}$$ and $$x_3 = \frac{\pi}{2}$$ so the values of $$\cos x$$ are simple.

I managed to get to the last 2 questions which asks me the method to choose the $$x_1,x_2,x_3$$ so that the function approximation is more precise and to give him a polynomial approximation with $$e_{max} < 0.002$$

the teacher recommends us to use maxima and gnu plot to find them. the most "evident" way seems to loop through the values in $$I$$ with a 0.001 incrementation and test them but maybe i can use a dichotomic search-like approach ?

if anyone could confirm my instincts or give me search leads i'd be really grateful

thank you by advance and i'm sorry if my post is a little messy

• I don't understand the role of $b$ – Damien Dec 3 '18 at 8:59
• Please have a look at Remez algorithm – Damien Dec 3 '18 at 9:08

## 1 Answer

So far I understand, you know how to solve for $$a, b, c$$ and how to get the values of $$e_{\rm max}$$. My suggestion is to keep $$x_1 = 0$$, $$x_3 = \pi/2$$ and let $$x_2$$ change. For each $$x_2$$ calculate $$e_{\rm max}$$ and make a plot of the results, this is what you should get

• Perfect, i didn't think of letting x1 and x3 and just change x2 thank you very much – Edo Youss Dec 3 '18 at 9:17
• i'm sorry i'm asking you another question,how did you compute this e_{max} because i tried in python and in maple and i couldn't get it like you did – Edo Youss Dec 6 '18 at 18:12
• @EdoYouss Sorry, I was making a very dumb mistake. Do your results agree now? – caverac Dec 6 '18 at 23:43
• Yeah, this is more like it thank you very much for your edit – Edo Youss Dec 6 '18 at 23:46