Code Monkey home page Code Monkey logo

symbolism's Introduction

Symbolism - A Computer Algebra Library for C#

Library that implements automatic simplification of algebraic expressions in C#.

To get an idea of the kinds of expressions it handles, see the tests in this file.

The automatic simplification algorithm comes from the book "Computer Algebra and Symbolic Computation: Mathematical Methods" by Joel S. Cohen.

The core of the system is in Symbolism.cs.

Symbolism currently targets .NET Standard 2.0 and thus can be used in .NET projects on Windows, Linux, and Mac.

Nuget package available here.

Setup on Linux

Tutorial on how to build and run a simple Symbolism program on Linux.

Examples

The "PSE 5E" examples and problems in the unit tests are from the textbook "Physics for Scientists and Engineers, 5th Edition" by Serway and Jewett. Here's an index of some of the examples.

Here's a walk-through of solving a physics problem.

A slightly more complex walk-through.

Walk-through of solving a laws of motion problem.

In action:

Unit test for that example.

See also

Symbolism began as a port of the Scheme MPL library to C#.

GiNaC and SymbolicC++ are of course very inspirational.

References

Computer Algebra and Symbolic Computation: Elementary Algorithms by Joel S. Cohen

Computer Algebra and Symbolic Computation: Mathematical Methods by Joel S. Cohen

symbolism's People

Contributors

dharmatech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symbolism's Issues

Commit 59c6a6f does not build on VS 2013 / VS 2015

Hello,

I've tried to compile the most recent build 59c6a6f on both VS 2013 as well as VS 2015 - without success.

Since the only 2 files that cause issues are PolynomialDivision.cs and PolynomialGcd.cs, I'm assuming it is due to the attempt to use tuples of the System.ValueTuple nuget package, for example

public static (MathObject quotient, MathObject remainder) PolynomialDivision(MathObject u, MathObject v, MathObject x)

Could you describe in detail how you made the project compile on VS 2013 / VS 2015 ?

some dirty code to look into

I've wrote some code using Symbolism. It is interesting enough to be
shared. It is not ready to be integrated and I don't have time to
finish it. So I publish the mess as is.

The code includes:

  • MakeFunction() to create custom functions,
  • Subs() to substitute (custom) functions using callback (and
    SubsFunctionStatic() to substitute variadic functions),
  • my own tree traversal with replacement by callback (like
    DeepSelect() but goes bottom-to-top),
  • Output to LaTeX, either to .tex file or to .html file that includes
    MathJax,
  • parser based on compilation (just for fun, not for real use!),
  • some examples of usage,
  • minor stuff.

https://gist.github.com/AlekseyCherepanov/53ec25566453686b95cc

Potential typo in Cos

In Cos.CosProc() should

if (n == 2)
{
    if (Mod(k, 2) == 1) return 0;
}

be

if (n == 2)
{
    if (Mod(k, 4) == 1) return 0;
}

?

This would match the pattern of modding by n*2 and the Sin.SinProc() method.

Missing Arccos func ?

Hello,

I noticed a trigo function is missing : arccos, while the arcsin (asin) function is present. Do there is a particular reason for this ?

Thanks,

Sylvain
acos

.AlgebraicExpand() hangs on C * (2 ^ (x + 1))

using System;
using Symbolism;
using Symbolism.AlgebraicExpand;

namespace my
{
    public class My
    {
        static void Main(string[] args)
        {
            var C = new Symbol("C");
            var x = new Symbol("x");
            var t = C * (2 ^ (x + 1));
            Console.WriteLine("before hang");
            t.AlgebraicExpand();
        }
    }
}

Good job. I have done some cleaning to all code

If you're interest to check it, you only have to tell me.
The changes includes:
formatted the text with the better indentation
Added LINQ expression
Invert conditions to optimise
Change recursion for cycles
etc
I'm interested in make a project based on it for Engineering Equations.
Thanks so much

.Simplify() seems confusing or inconvenient

I find .Simplify() method quite inconvenient: it is not a part
MathObject, it is a part of Sum and Product classes (and maybe some
others). It'd be more convenient to call it through general interface.

On the other hand, .Simplify() is not needed usually because Symbolism
simplifies automatically. It is needed if one changes .elts list
directly (there may be an Exception on following manipulations without
the simplification). Moving it to the interface may cause assumptions
that it is intended for regular use.

This bug report shares my concerns and documents observations. I don't
insist that it is a defect.

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.