Bug: f(z)=z and c=1/3-i/3 produces f(c)= -i/3 rather than f(c) = 1/3 - i/3
sadqiang opened this issue · 4 comments
sadqiang commented
The following code snippet produces (0,-0.33333)
rather than (0.33333,-0.33333)
.
using System;
using static MathNet.Symbolics.SymbolicExpression;
using static System.Console;
using static System.Numerics.Complex;
using Complex = System.Numerics.Complex;
namespace MathNetSymbolicsCompile
{
class Program
{
static readonly Complex i = ImaginaryOne;
static void Main(string[] args)
{
var z = Variable("z");
Func<Complex, Complex> f = (z).CompileComplex("z");
Complex c = 1/3 - i/3 ;
WriteLine(f(c));
}
}
}
The following information might be irrelevant.
I successfully tested it with Xamarin.Forms for UWP, Android and iOS. It is really multi platform library.
sadqiang commented
I tried again with real numbers, the same bug occurs.
var x = Variable("x");
Func<double, double> f = (x).Compile("x");
double c = 1 / 3;
Result.Text = f(c).ToString();
sadqiang commented
Oh... I think I know the solution.
FoggyFinder commented
1/3 = 0 - integer division
sadqiang commented
@FoggyFinder : That is what I was thinking several seconds ago.