mathnet / mathnet-symbolics

Math.NET Symbolics
http://symbolics.mathdotnet.com
MIT License
352 stars 67 forks source link

Added customized function (a little ugly) #101

Open ingted opened 2 years ago

ingted commented 2 years ago

For supporting code like the following:

#r @"src\Symbolics\bin\Debug\netstandard2.0\MathNet.Symbolics.dll"
#r @"nuget:MathNet.Numerics"
#r @"nuget:FsUnit"
#r @"nuget:FParsec"
#r @"nuget:MathNet.Numerics.FSharp"
#load @"src\Symbolics.Tests\Global.fs"

open MathNet.Numerics
open MathNet.Symbolics
open Global
open Operators
open VariableSets.Alphabet
type Expr = SymbolicExpression

let symV = Symbol "v"
let symW = Symbol "w"
let symX = Symbol "x"
let symY = Symbol "y"
let symZ = Symbol "z"

open Definition
define "test" ([symV; symW], (v + w)*2)
SymbolicExpression(Infix.parseOrThrow("2^test(x, 2 * x)")).Evaluate(dict[ "x", FloatingPoint.Real 2.0; ])

Result:

val it : FloatingPoint = Real 4096.0

Code:

SymbolicExpression(cFun("test", [x + (fromInt32 10); (fromDouble 100.0)])*2).Evaluate(dict[ "x", FloatingPoint.Real 9.0; ])

Result:

val it : FloatingPoint = Real 476.0
ingted commented 2 years ago

Actually I never thought this PR would be merged. Just let some one who needs things like those should not appear in README to know there is a workaround.

On Sat, Mar 19, 2022, 15:03 FoggyFinder @.***> wrote:

@.**** commented on this pull request.

In README.md https://github.com/mathnet/mathnet-symbolics/pull/101#discussion_r830450282 :

@@ -1,6 +1,77 @@ -Math.NET Symbolics +Math.NET Symbolics (With Matrix/Vector/Customized Function supported) + +2022-03-12 Now there is a private repo which supports DiffSharp Tensor within Math.NET Symbolics. (very rough/early stage)

(Why private? Because it is just like a toy and still a lot of works to do... )

Then, it should not be mentioned in ReadMe. Feel free to create issue though.

— Reply to this email directly, view it on GitHub https://github.com/mathnet/mathnet-symbolics/pull/101#discussion_r830450282, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAXFCO4DBTWVRTFOIJYRDLVAV33LANCNFSM5PNIX3HQ . You are receiving this because you authored the thread.Message ID: @.***>