Skip to content

Instantly share code, notes, and snippets.

@leppie
Created August 14, 2013 10:10
Show Gist options
  • Save leppie/6229691 to your computer and use it in GitHub Desktop.
Save leppie/6229691 to your computer and use it in GitHub Desktop.
Bad math
using MathNet.Numerics;
using System;
using System.Numerics;
namespace ConsoleApplication21
{
class Program
{
static void Main(string[] args)
{
Complex c1 = -1234000000;
Complex c2 = 1234000000;
Console.WriteLine(c1.InverseSine());
Console.WriteLine(c2.InverseCosine());
Console.WriteLine(Complex.Asin(c1));
Console.WriteLine(Complex.Acos(c2));
/* output
(NaN, Infinity)
(NaN, Infinity)
(0, 16.3983624574988)
(1.5707963267949, 16.3983624574988)
*/
// see: https://connect.microsoft.com/VisualStudio/feedback/details/790328/complex-asin-and-complex-acos-in-system-numerics-yields-incorrect-results#details
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment