Re: Mathematica Precision
- To: mathgroup at smc.vnet.net
- Subject: [mg8521] Re: [mg8489] Mathematica Precision
- From: Daniel Lichtblau <danl>
- Date: Thu, 4 Sep 1997 02:20:17 -0400
- Sender: owner-wri-mathgroup at wolfram.com
David Djajaputra wrote: > > --------------E7F4C761F09A86D88F419661 > > To all Mathematica lovers out there, > > I would really appreciate it if anyone can give me helpful comment on > this problem. > I need to work with the following equation: > > Solve[a(x + y) + c (Sqrt[1 - x^2] + Sqrt[1 - y^2])== e, y] > > It gives two roots. Fine. I then define one root as a new function: > > Arguemin[x_, a_, c_, e_] := > (a e -a^2 x - a c Sqrt[1 - x^2] -Sqrt[-c^2 e^2 + 2 a c^2 e x + c^4 x^2 > + 2 c^3 e Sqrt[1-x^2] - 2 a c^3 Sqrt[1-x^2] > + a^2 c^2 (1 - x^2)])/(a^2 + c^2) > > and plug it back into the original equation: > > Checking[x_, a_, c_, e_]:= > a( x + Arguemin[x,a,c,e]) + > c (Sqrt[1 - x^2] + Sqrt[1 -(Arguemin[x,a,c,e])^2]) > > I set the precision to infinity: > > $MaxExtraPrecision = Infinity > > If I run Checking[x,a,c,e], it should give me result=e, right? (In my > problem, a=1-Cos(s) and c=Sin(s), and I choose s=0.1 here.) > > Checking[Cos[0.4], 1-Cos[0.1], Sin[0.1], 0.1] > > 0.100252 > > It doesn't. For other values of s, it is even worse. Couldn't > Mathematica do better than > this? > > Much thanks in advance, > > David > The following should test the solutions with the values you had in mind. In[13]:= eqn = a(x + y) + c (Sqrt[1 - x^2] + Sqrt[1 - y^2]) - e; In[14]:= soln = Solve[eqn==0, y]; In[15]:= vals = eqn /. soln; In[16]:= newvals = (vals /. {a->1-Cos[s], c->Sin[s], e->0.1, x->Cos[0.4]}) /. s->0.1 -17 -17 Out[16]= {2.77556 10 , 1.38778 10 } I would imagine you resorted to manual typing instead of automatic substitution. I can detect at least one missing factor in your "solution," and this might account for the numerical discrepancy. By the way, you are doing a check in machine arithmetic, hence the $MaxExtraPrecision setting is unlikely to have any effect. Another remark I'll make is that the original equation has radicals in the solve variable, hence for specific values of the parameters the solutions found might actually be parasite solutions. A simple example of a parasite solution would be: In[26]:= Solve[Sqrt[x+1] + x == 3, x, VerifySolutions->False] 7 - Sqrt[17] 7 + Sqrt[17] Out[26]= {{x -> ------------}, {x -> ------------}} 2 2 The second value fails to solve the equation, and is an artifact of the Solve process. In your example there are parameters and for various values one or the other (or both) solutions might fail to satisfy your original equation. Daniel Lichtblau Wolfram Research