xFunc.Maths
4.1.0
See the version list below for details.
dotnet add package xFunc.Maths --version 4.1.0
NuGet\Install-Package xFunc.Maths -Version 4.1.0
<PackageReference Include="xFunc.Maths" Version="4.1.0" />
paket add xFunc.Maths --version 4.1.0
#r "nuget: xFunc.Maths, 4.1.0"
// Install xFunc.Maths as a Cake Addin #addin nuget:?package=xFunc.Maths&version=4.1.0 // Install xFunc.Maths as a Cake Tool #tool nuget:?package=xFunc.Maths&version=4.1.0
Master:
Dev:
xFunc.Maths:
xFunc.DotnetTool:
xFunc
xFunc is a simple and easy to use application that allows you to build mathematical and logical expressions. It's written on C#. The library includes well-documented code that allows developers to parse strings to expression tree, to analyze (derivate, simplify) expressions by using lexer, parser and etc.
xFunc is a small-sized and portable application that you can use to create complex mathematical expressions which will be automatically computed. It can be used by teachers and students alike.
Note: The WPF application (xFunc UI) was migrated to a separate repository xFunc.UI.
Features:
- Calculating expressions (supported functions and operations);
- Supporting measures of angles;
- Derivative and simplifying expressions;
- Plotting graphs;
- Truth tables;
- Supported Framework: .NET Standard 2.1+;
Usage
The main class of xFunc library is Processor
.
Processor
It allows you to:
Parse:
var processor = new Processor();
var exp = processor.Parse("2 + x");
// 'exp' will contain the expression tree for later use
// you can calculate it or process it by analyzers (Differentiator, Simplifier, etc.)
// 'exp' has a parameter
// we should provide a value for varible 'x'
var parameters = new ParameterCollection
{
{ "x", 10 }
};
var result = exp.Execute(parameters);
// result will be equal to 12
Note: The Parse
method won't simplify expression automatically, it will return the complete representation of provided string expression.
Solve:
This method parses string expression (like Parse
method) and then calculates it (returns object which implements IResult
interface).
There is two overloads of this method (common and generic). The common returns just IResult
(you can access result by Result
property). The generic allows to return specific implementation of IResult
(eg. NumberResult
).
var processor = new Processor();
processor.Solve<NumberResult>("2 + 2"); // will return 4.0 (double)
// or
processor.Solve("2 + 2").Result; // will return 4.0 (object)
If your expression has any parameter, you need to assign a value to it (otherwise xFunc will throw an exception), because Processor
has a build-in collection of parameters and user functions, you don't need to use ExpressionParameters
directly:
processor.Solve("x := 10");
// or explicitly throught Parameters property
processor.Parameters.Variables.Add("x", 10);
Note: The Solve
method automatically simplifies expression, to control this behavior you can use simplify
argument. It's useful for differentiation, because it will eliminate unnecessary expression nodes.
Simplify:
var processor = new Processor();
processor.Solve<ExpressionResult>("simplify(arcsin(sin(x)))");
// or
processor.Simplify("arcsin(sin(x))");
// will return simplified expression = "x"
Detailed simplification rules
Differentiate:
var processor = new Processor();
processor.Solve<ExpressionResult>("deriv(2x)");
// or
processor.Differentiate("2x");
// will return "2"
You can specified variable (default is "x") of differentiation:
var processor = new Processor();
processor.Differentiate("2y", Variable.Y); // will return "2"
processor.Differentiate("2x + sin(y)", new Variable("x")); // will return "2"
Performance
Processor
Version | Method | Mean | Allocated |
---|---|---|---|
3.7.3 | Parse | 166,581.4 ns | 63770 B |
4.0.0 | Parse | 24,604.93 ns | 4760 B |
3.7.3 | Solve | 232,498.0 ns | 96952 B |
4.0.0 | Solve | 39,971.82 ns | 10673 B |
Bug Tracker
Please, if you have a bug or a feature request, create a new issue. Before creating any issue, please search for existing issues.
License
xFunc is released under MIT License.
Thanks
Fluent.Ribbon
Azure Pipelines
Coverlet
ReportGenerator
xUnit
Moq
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Collections.Immutable (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
4.4.1 | 7,646 | 12/10/2023 | |
4.4.0 | 990 | 9/13/2023 | |
4.3.0 | 267 | 8/8/2023 | |
4.2.0 | 1,234 | 7/5/2023 | |
4.1.0 | 5,881 | 5/23/2022 | |
4.0.1 | 2,179 | 4/29/2021 | |
4.0.0 | 17,413 | 1/22/2021 | |
3.7.3 | 1,581 | 10/6/2020 | |
3.7.2 | 854 | 9/4/2020 | |
3.7.1 | 3,243 | 7/21/2019 | |
3.7.0 | 968 | 6/30/2019 | |
3.6.0 | 1,375 | 4/13/2019 | |
3.5.0 | 1,489 | 2/19/2018 | |
3.4.0 | 2,506 | 2/26/2017 | |
3.3.0 | 1,528 | 12/18/2016 | |
3.2.1 | 1,571 | 12/4/2016 | |
3.2.0 | 1,538 | 12/3/2016 | |
3.1.0 | 1,587 | 10/14/2016 | |
3.0.0 | 1,830 | 7/10/2016 | |
2.15.16 | 5,483 | 5/5/2015 | |
2.15.15 | 1,788 | 11/18/2014 | |
2.15.12 | 1,540 | 6/19/2014 | |
2.15.10 | 1,470 | 6/13/2014 | |
2.15.8 | 1,420 | 6/11/2014 | |
2.15.7 | 1,470 | 5/29/2014 | |
2.15.6 | 1,475 | 5/26/2014 | |
2.15.5 | 1,460 | 5/17/2014 | |
2.15.4 | 1,476 | 5/14/2014 | |
2.14.1 | 1,495 | 5/6/2014 | |
2.13.3 | 1,593 | 5/3/2014 | |
2.13.2 | 1,510 | 4/29/2014 | |
2.13.0 | 1,436 | 4/28/2014 | |
2.12.3 | 1,478 | 4/24/2014 | |
2.12.1 | 1,495 | 4/22/2014 | |
2.12.0 | 1,639 | 4/20/2014 | |
2.11.4 | 1,578 | 4/6/2014 | |
2.11.3 | 1,548 | 3/22/2014 | |
2.11.2 | 1,557 | 2/22/2014 | |
2.11.1 | 1,533 | 2/21/2014 | |
2.11.0 | 1,553 | 2/18/2014 | |
2.10.2 | 1,525 | 11/12/2013 | |
2.10.1 | 1,502 | 11/6/2013 | |
2.10.0 | 1,476 | 11/4/2013 | |
2.9.0 | 1,511 | 11/2/2013 | |
2.8.3 | 1,503 | 10/25/2013 | |
2.8.2 | 1,459 | 10/21/2013 | |
2.8.1 | 1,461 | 10/20/2013 | |
2.7.1 | 1,503 | 10/6/2013 | |
2.7.0 | 1,513 | 10/5/2013 | |
2.5.11 | 1,468 | 9/25/2013 | |
2.5.9 | 1,519 | 9/23/2013 | |
2.5.8 | 1,447 | 9/22/2013 | |
2.5.5 | 1,478 | 9/15/2013 | |
2.5.3 | 1,510 | 9/13/2013 | |
2.5.2 | 1,495 | 9/11/2013 | |
2.4.1 | 1,551 | 8/17/2013 | |
2.3.2 | 1,790 | 7/12/2013 | |
2.3.0 | 1,754 | 6/26/2013 | |
2.2.2 | 1,600 | 6/18/2013 | |
2.2.1.1 | 1,662 | 6/13/2013 | |
2.2.1 | 1,670 | 6/13/2013 | |
2.2.0 | 1,606 | 6/8/2013 | |
2.1.1.2 | 1,523 | 4/27/2013 | |
2.1.1 | 1,695 | 4/14/2013 | |
2.1.0.4 | 1,571 | 4/3/2013 | |
2.1.0.1 | 1,596 | 3/22/2013 | |
2.0.7 | 1,657 | 3/15/2013 | |
2.0.6 | 1,620 | 3/14/2013 | |
2.0.5 | 1,624 | 3/9/2013 | |
2.0.2.7 | 1,531 | 3/2/2013 | |
2.0.2.6 | 1,541 | 2/28/2013 | |
2.0.2.3 | 1,577 | 2/17/2013 | |
2.0.2 | 1,616 | 2/9/2013 | |
2.0.0.1 | 1,541 | 2/7/2013 | |
2.0.0 | 1,589 | 2/7/2013 |