home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   sci.math.symbolic      Symbolic algebra discussion      10,432 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 8,844 of 10,432   
   Waldek Hebisch to Nasser M. Abbasi   
   Re: on sin(very large number)   
   04 Aug 15 12:12:04   
   
   From: hebisch@antispam.uni.wroc.pl   
      
   Nasser M. Abbasi  wrote:   
   > I was answering someone question on Matlab forum, and noticed   
   > something interesting.   
   >   
   > Maple:   
   > ========   
   > Digits::60: sin(2*10^30): evalf(%);   
   > 0.17950046751493908795061771231643809505098047699633484280836744\   
   >   698514457349325219   
   >   
   > Matematica:   
   > ===========   
   > In[21]:= N[Sin[2*10^30], 60]   
   > Out[21]= 0.179500467514939087950617712316438095050980476996334842808367   
   >   
   > Mupad:   
   > ======   
   > Digits:=60:   
   > simplify(sin(2.0*10^30));   
   > -0.6054240282319655434839500429688996518962085247039794921875   
   >   
   > But when calling mupad from Matlab, now it gives different answer   
   > (same as Maple and Mathematica)   
   >   
   > >> evalin(symengine,'DIGITS := 60: simplify(sin(2.0*10^30))')   
   > 0.179500467514939087950617712316438095050980476996334842808367   
   4698514564171539337   
   >   
   > But Matlab gives different answer   
   > =================================   
   > >> sin(2*10^30)   
   >   -0.018662125294758   
   >   
   > Which is the correct result, and what is the algorithm used for such   
   > evaluations when the argument of trig is large?   
      
   "correct" depends of definition.  Of course the '0.1795...' approximation   
   has much smaller error than the other one.  However, if you   
   perform calculations in strightforward way using machine arithmetic   
   you get essentially random result.  So, the question is if   
   'sin' should do heroic effort to get smaller error.  There   
   is one school, which says yes.  In more extreme form they require   
   error smaller than half of machine precision, which means that   
   to deliver "correct" machine precision result one has to   
   use multiple precision calculations.  The other school says   
   that extra effort is normally wasted: when argument is approximate   
   then no heroics in 'sin' can salvage precision.  And for   
   precise arguments one can request evaluation of 'sin' in   
   better precision.   
      
   Note, that for 'sin' there are tricks to substantialy reduce   
   cost of multiple precision calculations.  But no such tricks   
   are known for nonelementary functions (in particular for   
   multivariate library functions).   
      
   --   
                                 Waldek Hebisch   
   hebisch@antispam.uni.wroc.pl   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca