Code Monkey home page Code Monkey logo

sysharp's Introduction

SySharp

SySharp is simple library to symbolic calcualtions to demonstrate the power of expressions trees in C#.

The library can produce derivative function and simplify expressions.

Demo

To start the experiments you can clone the repository into your projects' directory:

cd $home/source
git clone https://github.com/markshevchenko/sysharp
cd sysharp
dotnet build -c Release

Open "C# Interactive" window in Visual Studio. Please note that csi.exe hasn't been supported the core mode, so you need Visual Studio.

Type these commands:

#reset core
#r "source/sysharp/SySharp/bin/Release/net5.0/SySharp.dll"
using SySharp;

Don't forget to check the path. source/sysharp/SySharp/bin/Release/net5.0 will be valid, if you have cloned the repository to the $home/source directory.

Now we can experiment with the library. Let's' find out the derivative of the function x2:

Symbolic.Derivative(x => x * x)

The answer is x => ((x * 1) + (1 * x)). To see it clearly we need call the ToString() method:

Symbolic.Derivative(x => x * x).ToString()

It's too complicated, isn't it?

We can simplify expressions with the help of the method Simplify():

Symbolic.Derivative(x => x * x).Simplify().ToString()

Now the anwer is x => (2 * x). Much better.

At the end we can calculate the value of derivative function:

var d = (Func<double, double>)Symbolic.Derivative(x => Math.Sin(Math.Pow(x, 3))).Compile();
d(3)

The value of the function (sin x3)' at x = 3 will be equal to -7.887747835813577.

sysharp's People

Contributors

markshevchenko avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

shurikev

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.