bugGNU Octave - Bugs: bug #29330, Highly Innacurate Trigonometric...

 
 

bug #29330: Highly Innacurate Trigonometric Functions

Submitted by:  Derek O'Connor <derekroconnor>
Submitted on:  Thu 25 Mar 2010 12:07:38 AM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: InvalidAssigned to: None
Originator Name: Derek O'ConnorOpen/Closed: Closed
Release: 3.2.3Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Sun 28 Mar 2010 12:53:15 PM UTC, comment #6:

Correction to my previous post:

I mis-counted the number of digits in the Octave result for sin(1e22) = -8.52200849767189e-01. This is correctly rounded to 15 digits, not 16.

Sorry for the mistake,

Derek O'Connor

Derek O'Connor <derekroconnor>
Sun 28 Mar 2010 12:48:27 PM UTC, comment #5:

Dear Jarno,

Your guess about MingW being the source of the inaccurate trig. functions seems to be correct. I have just installed the latest Cygwin and here is what I get:

GNU Octave Version 3.2.4
Operating System: CYGWIN_NT-6.1-WOW64 1.7.2(0.225/5/3) 2010-03-24 21:12 i686

Dell Precision 690, Intel 2xQuad-Core E5345 @ 2.33GHz
16GB RAM, Windows7 64-bit Professional.

octave:8> x=1e22;
octave:9> disp([sin(x) cos(x) tan(x)])
-8.52200849767189e-01 5.23214785395139e-01 -1.62877822560690e+00

These results are much better but notice that sin(1e22) has an error of 1 in the last place: the correctly-rounded-to-16-digits value is -8.522008497671888e-01 because at much higher precision sin(1e22) = -8.522008497671888 | 01772...e-1

This may seem to be a trivial matter but Intel, AMD, IBM, Jean-Michel Muller, William Kahan, etc., think it is very important, and spend a lot of time, effort, and money to get the correctly-rounded results. Remember that Intel in 1995 nearly lost $450,000,000 because they messed up the 'simple' floating point x/y calculation.

Thanks for your attention.

Derek O'Connor

Derek O'Connor <derekroconnor>
Thu 25 Mar 2010 06:25:04 AM UTC, comment #4:

Octave relies on the standard C library for calculating sin, cos and tan. It is not within the scope of Octave to attempt to fix its build environment except in limited trivial cases.
Octave 3.4 will include gnulib, which can help combat certain portability problems, but in general it is unavoidable that defects in the host environment (MinGW in this case, I think) project themselves into Octave. The problem is most likely in MinGW, so hopefully will be fixed there. It will help if you can report it.

Please remember that Octave comes with no warranty.

Jaroslav Hajek <highegg>
Thu 25 Mar 2010 01:43:56 AM UTC, comment #3:

Dear Jarno Rajahalme,

I apologise for mis-reading your comment which said "So this seems to be Windows version related problem."

I skipped over the word 'version'. Thus, we are in agreement: the Windows version of Octave does not work for the elementary trig. functions.

Derek O'Connor.

Derek O'Connor <derekroconnor>
Thu 25 Mar 2010 01:19:08 AM UTC, comment #2:

On Window 2000, Vista, and Windows 7, Matlab (all versions) using IEEE double precision give
x=10^22;[sin(x);cos(x);tan(x)]

ans =

-8.522008497671888e-001
5.232147853951390e-001
-1.628778225606899e+000

A Windows problem? Hardly.

It looks to me like an Octave-on-Windows problem.

If Octave does not work on Windows it should not release Windows versions.

Derek O'Connor.

Derek O'Connor <derekroconnor>
Thu 25 Mar 2010 12:32:34 AM UTC, comment #1:

Octave 3.2.3 (on Mac) gives:

octave:1> sin(10^22)
ans = -0.85220
octave:2> cos(10^22)
ans = 0.52321
octave:3> tan(10^22)
ans = -1.6288
octave:4>

Seems right to me.

On Windows XP, Octave 3.0.3 gives the same inaccurate results that you reported:

octave.exe:1> sin(10^22)
ans = 0.41214
octave.exe:2> cos(10^22)
ans = -0.91112
octave.exe:3> tan(10^22)
ans = -0.45235
octave.exe:4>

So this seems to be Windows version related problem.

Jarno Rajahalme

Anonymous
Thu 25 Mar 2010 12:07:38 AM UTC, original submission:

Octave 2.3.2 gives these results:

> sin(10^22) = 0.4121434
> cos(10^22) = -0.911119
> tan(10^22) = -0.4523486


The correct results are:

sin(10^22) = -8.52200849767188801772705893753029368261762150410044e-1

cos(10^22) = 5.23214785395138945497594473384709492140919972439388e-1

tan(10^22) = -1.62877822560689887854937593693954851354515116817022e0

These were obtained using PariGP 2.4.2 and verified using other high-precision
calculators.

The usual cause of such errors is inaccurate argument reduction and not the
polynomial approximation.

See: http://www.derekroconnor.net/Software/Ng--ArgReduction.pdf

and: http://perso.ens-lyon.fr/jean-michel.muller/SecondEdition.html

Derek O'Connor <derekroconnor>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by highegg (Posted a comment)
  • -unavailable- added by derekroconnor (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 30 Mar 2010 06:48:35 PM UTCrik5Open/ClosedOpen=>Closed
    Tue 30 Mar 2010 06:46:48 PM UTCrik5StatusNone=>Invalid

    Back to the top


    Powered by Savane 3.1-cleanup1