Trigonometric functions failure
Status: Beta
Brought to you by:
coder0xff
Hello,
I compiled the source (Commit 393210) using Visual Studio 2010 and I get some strange behavior with Sin and Cos functions for some specific kind of values.
It seems that the range reduction algorithm is failing but I may be wrong since I didn't read all the source code at that time.
Here are some examples of the problem:
Expression | Returns | Where it should be |
Quadruple.Cos(Quadruple.HalfPi) | 3.141592653589793238462643383279502 | 0 |
Quadruple.Cos(Quadruple.HalfPi + Quadruple.Pi) | 6.283185307179586476925286766559005 | 0 |
Quadruple.Cos(Quadruple.FromString("7.5") * Quadruple.Pi) | 25.13274122871834590770114706623603 | 0 |
Quadruple.Sin(Quadruple.Pi) | 3.141592653589793238462643383279502 | 0 |
Quadruple.Sin(Quadruple.TwoPi) | 6.283185307179586476925286766559005 | 0 |
Quadruple.Sin(Quadruple.FromString("6") * Quadruple.Pi) | 18.84955592153875943077586029967702 | 0 |
Thanks Philippe
Anonymous
The problem can be solved by replacing the expression "if (temp.IsZero()) return v;" at the line 745 of the file __float128.cpp by "if (temp.IsZero()) return QuadZero;"
Last edit: Philippe 2014-08-22