Re: Trigonometric math functions
- To: mathgroup at smc.vnet.net
- Subject: [mg44572] Re: Trigonometric math functions
- From: poujadej at yahoo.fr (Jean-Claude Poujade)
- Date: Fri, 14 Nov 2003 04:43:20 -0500 (EST)
- References: <boig47$og2$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Bruno" <bpa at BPASoftware.com> wrote in message news:<boig47$og2$1 at smc.vnet.net>... > Hi all, > > I would like to implement an arc cos function on a 16 bits µcontroller > (optimized sin() and cos() function are welcome). > > Does someone have some sources or an algorythm in this way ? > > Thanks in advance, > > Regards. (Sorry my previous post was a wrong version ! ) In[1]:=(* Why not simply use a series expansion? *) In[2]:=(s1=Series[ArcCos[x],{x,0,3}]//Normal )//InputForm Out[2]//InputForm=Pi/2 - x - x^3/6 In[3]:=(s2=Series[Cos[a],{a,0,4}]//Normal)//InputForm Out[3]//InputForm=1 - a^2/2 + a^4/24 In[4]:=(sol=Solve[x\[Equal]s2,a][[2]] )//InputForm Out[4]//InputForm={a -> Sqrt[2]*Sqrt[3 - Sqrt[3]*Sqrt[1 + 2*x]]} In[5]:=lim=x/.FindRoot[s1-a/.sol,{x,0.4}] Out[5]=0.483528 In[6]:=ClearAll[acos]; acos[0]=Pi/2; acos[1]=0; acos[x_ /; 0<x<lim]:=Pi/2-x-x^3/6 ; acos[x_ /; lim<x<1]:=Sqrt[2]*Sqrt[3-Sqrt[3]*Sqrt[1+2*x]] ; acos[x_ /; x<0]:=Pi-acos[-x]; In[12]:=Plot[{ArcCos[x],acos[x]},{x,-1,1}] no difference can be seen with a naked eye! --- jcp