Comments (5)
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.
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.
@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.
@diluculo : Has your fixing be committed? I just test but the issue still exist.
from mathnet-symbolics.
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)
- Processing does not end
- "not supported" exception with divide by zero in equation
- FSI
- Errors parsing and evaluating complex-valued string
- Evaluation of an expression dealing with Vector
- Bug: No control over culture for string formatting HOT 1
- Solving simple equations or HOT 3
- Expression.Zero.Equals() Bug? HOT 2
- Rational.Simplify gets stuck in endless loop HOT 3
- Problem with eager numeric calculation HOT 1
- Automatically escape special LaTeX characters in symbol names HOT 4
- What about cooperation? HOT 3
- Latex HOT 8
- Multiplication signs being removed by Latex.formatvisual function HOT 4
- Simplify a string of variables and numbers - vb HOT 2
- How to use variables in algebra problems using a string? HOT 2
- How to add Parsing and Evaluation of the min and max functions HOT 2
- Approximation.Real vs FloatingPoint.Real
- No effective way to generate large sums
- Order of expressions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mathnet-symbolics.