Skip to content

Releases: AntonovAnton/math.evaluation

2.2.4

18 Oct 20:42
f60b76d
Compare
Choose a tag to compare

Improves:
Searching of a math entity in the prefix tree is improved. #75

Fixes:
Methods for complex numbers are added to the IMathContext and to the IMathParameters interfaces.

2.2.3

14 Oct 13:49
69878e0
Compare
Choose a tag to compare

Improvements:

  1. The handling of the sign for the components of the complex number has been enhanced to account for cases such as zero, etc. #74
  2. Added benchmarks for complex numbers. #74
  3. Added support of the IIF function to the Programming Math Context (ProgrammingMathContext class). Conditional operation: IIF(condition, valueIfTrue, valueIfFalse), where the valueIfTrue and valueIfFalse arguments are optional. #74

2.2.2

12 Oct 08:46
1c50769
Compare
Choose a tag to compare

Fixes: #72
The Compile(this string mathString, IMathContext? context = null, IFormatProvider? provider = null) extension method for the string type without T parameters has been removed to avoid conflicts between the context argument and the parameters argument in other overload of the Compile method.
Compilation without parameters doesn't make sense, anyway you still can use the MathExperssion.Compile() method instead of the string extension method.

2.2.0 / Supports Complex numbers.

10 Oct 21:49
4fd4209
Compare
Choose a tag to compare

Improves:
Added support of complex numbers. #69

Complex numbers are written in the form a ± bi, where a is the real part and bi is the imaginary part.
Below is an example of evaluating a mathematical expression that contains complex numbers:

var expression = new MathExpression("sin(2 + 3i) * arctan(4i)/(1 - 6i)", new ComplexScientificMathContext());
var value = expression.EvaluateComplex();

Evaluation steps:

1: 3i = <0; 3>;
2: 2 + 3i = <2; 3>;
3: sin(2 + 3i) = <9.15449914691143; -4.168906959966565>;
4: 4i = <0; 4>;
5: arctan(4i) = <1.5707963267948966; 0.25541281188299525>;
6: sin(2 + 3i) * arctan(4i) = <15.444645882739138; -4.2103273709720295>;
7: 6i = <0; 6>;
8: 1 - 6i = <1; -6>;
9: sin(2 + 3i) * arctan(4i)/(1 - 6i) = <1.1001786515830083; 2.3907445385260218>; //completed

2.1.0

01 Oct 15:11
bf283fe
Compare
Choose a tag to compare

Improves:
Added the Evaluating event. #67

By using this event, you can debug or log the steps of a math expression's evaluation. This event is triggered at each step during the evaluation process. The following code demonstrates how to use to this event:

using var expression = new MathExpression("-3^4sin(-PI/2)", new ScientificMathContext());
expression.Evaluating += (object? sender, EvaluatingEventArgs args) =>
{
    Console.WriteLine("{0}: {1} = {2};{3}",
        args.Step,
        args.MathString[args.Start..(args.End + 1)],
        args.Value,
        args.IsCompleted ? " //completed" : string.Empty);
};
  
var value = expression.Evaluate();

Output:

1: 3^4 = 81;
2: PI = 3.141592653589793;
3: PI/2 = 1.5707963267948966;
4: -PI/2 = -1.5707963267948966;
5: sin(-PI/2) = -1;
6: 3^4sin(-PI/2) = -81;
7: -3^4sin(-PI/2) = 81; //completed

NOTE: The Evaluating event is cleaned up in the Dispose method. So I recommend using the using statement to ensure proper disposal.

2.0.4

16 Sep 19:04
1edeb56
Compare
Choose a tag to compare

Enhanced the performance of operators that align with C# operators. #65

2.0.3

13 Sep 15:19
a9d36e4
Compare
Choose a tag to compare

Improved compilation #64.
Using static delegates in contexts. #63
Improved binding of variables and constants #62

2.0.2

08 Sep 23:11
0b51d83
Compare
Choose a tag to compare

Fixed compilation of a variable with exponentiation (x^y). #60

2.0.1

08 Sep 09:08
161f684
Compare
Choose a tag to compare

Improves:
Compilation of binary operators is improved. #58

2.0.0

06 Sep 16:40
d1fb26f
Compare
Choose a tag to compare

Added support for compiling mathematical expression strings into executable code, producing a delegate that represents the expression.

Example:

var fn = "ln(1/x1 + √(1/(x2*x2) + 1))"
    .Compile(new { x1 = 0.0, x2 = 0.0 }, new ScientificMathContext());

var value = fn(new { x1 = -0.5, x2 = 0.5 });

This enhancement allows for efficient evaluation of complex mathematical expressions by converting them into callable delegates.

Added MathExpression class instead of the MathEvaluator class that combines evaluation and compilation. Static methods are removed.