Git Product home page Git Product logo

Comments (5)

diluculo avatar diluculo commented on May 24, 2024 1

There is a bug: Linq.formatComplexLambda doesn't handle Constant.I

I think adding a line will fix the bug.

let formatComplexLambda ...
      let constant = function
            | I -> Some (Expression.Constant (complex 0.0 1.0) :> Expression)

And use j as ImaginaryOne in Parse.

      Func<Complex, Complex> f = Parse("z * z + j/2").CompileComplex("z");
      Complex c = 1.0 / 2.0 - i / 3.0;

from mathnet-symbolics.

sadqiang avatar sadqiang commented on May 24, 2024 1

I found the following enlightenment while I was sleeping.
However, this approach is risky because users can accidentally pass values other than i to the second argument.

using System;
using System.Numerics;

using static System.Console;
using static System.Numerics.Complex;
using static MathNet.Symbolics.SymbolicExpression;


    class Program
    {
        static readonly Complex i = ImaginaryOne;

        static void Main()
        {
            var z = Variable("z");
            Func<Complex, Complex, Complex> f = Parse("z * i").CompileComplex(nameof(z), "i");

            Complex c = 1 / 2.0 - i / 3;
            WriteLine(f(c, i));
        }
    }

from mathnet-symbolics.

diluculo avatar diluculo commented on May 24, 2024

@cdrnet, I have questions: Are the functions at compilation searched in System.Math or System.Numerics.Complex? Is this why Trigonometric.simplify used? So to speak, to avoid missing functions such as Coth? Is it possible to call functions from MathNet.Numerics.Trig or SpecialFunctions? I'd like to use Coth itself and Bessel functions.

coth(sqrt(10000000 j)) = 1, but sinh(sqrt(10000000 j)) = oo - oo j and cosh(sqrt(10000000 j)) = oo - oo j

from mathnet-symbolics.

sadqiang avatar sadqiang commented on May 24, 2024

@diluculo : Has your fixing be committed? I just test but the issue still exist.

from mathnet-symbolics.

pstricks-fans avatar pstricks-fans commented on May 24, 2024

Why didn't you also use nameof(i)? :-)

using System;
using System.Numerics;

using static System.Console;
using static System.Numerics.Complex;
using static MathNet.Symbolics.SymbolicExpression;


    class Program
    {
        static readonly Complex i = ImaginaryOne;

        static void Main()
        {
            var z = Variable("z");
            Func<Complex, Complex, Complex> f = Parse("z * i").CompileComplex(nameof(z), nameof(i));

            Complex c = 1 / 2.0 - i / 3;
            WriteLine(f(c, i));
        }
    }

from mathnet-symbolics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.