GithubHelp home page GithubHelp logo

65001 / abmath Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 2.15 MB

Math Library

License: MIT License

C# 99.99% Batchfile 0.01%
csharp math-library maths reverse-polish-notation reverse-polish-calculator rpn rpn-calculator shunting-yard shunting-yard-algorithm apportionment

abmath's People

Contributors

65001 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

abmath's Issues

Possible derivative bug

Describe the bug
The derivative( (x^2 - x)/e^(1/(2x)), x) may be producing an incorrect function as an output.

Expected behavior
(e^(-1/(2x))(4x^2 - x - 1))/(2x)

Optimization Chains with no Timeout

Describe the bug
If a user inputs arccos(1/A) the system will create an optimization chain that cannot end.

We should implement a generic solution that states that if an optimization results in the same state changes (10x) times in a row or something similar then the optimization should break out and return a message to the user that an optimization chain loop may have been detected.

Arity function bug

Describe the bug
Implicit multiplication interferes with the arity of variadic functions.

Current behavior

# Token Arity
0 1 0
1 2 0
2 3 0
3 sum 1
4 2 0
5 * 2

Expected behavior

# Token Arity
0 1 0
1 2 0
2 3 0
3 sum 3
4 2 0
5 * 2

Matricies, Lists, and Vectors Syntax

I want to be able to support matrices and matrix operations in AbMath. To do this we have to use one of several conventional ways to represent matrices on calculators.

To do this we need to make a breaking change on what constitutes left and right brackets and use aliasing to map them to lists and end parenthesis as appropriate.
In this context we will alias { to a new function named list and will alias } to ). This should allow us to use a the traditional matrix form of {{a,b},{c,d}} with this expanding out to list( list(a,b), list(c,d)).

A list is another name for a vector in this context. A vector of length n shall be treated as a matrix of size n x 1

We would need several rules in order for this to make sense when displayed to the user.

  1. A list with a single element shall just return that element. IE 3{3} will always return 9

  2. A list of lists shall be a matrix and for appropriate operators the matrix variants shall take precedence. We shall also need to include scalar and matrix variants of operators and all other functions and operators as logical shall be applied on all the elements of the data.

  3. A list, vector, or matrix inside in all general math functions shall be treated as a list.

  4. In certain functions such as total, avg, max, and min the list shall decompose and allow access to the underlying data contained therein. IE total({4,3,2}) - > total(4,3,2).

  5. For all other functions the list shall cause the function to be applied on all the elements of the data. ln({e,pi,2}) -> {ln(e),ln(pi),ln(2)} or ln( {{a,b},{c,d}}) -> { {ln(a), ln(b)}, {ln(c),ln(d)} }

All functions and operators shall be classified as requiring decomposition, distribution, or having special variants for matrix support.

Algebra Research

Is your feature request related to a problem? Please describe.
Is there a way we can do simple algebraic simplifications on an AST?

Describe the solution you'd like
Research required.

Describe alternatives you've considered
None.

Additional context
Add any other context or screenshots about the feature request here.

Change sum to total and make a new implemntation of sum

Is your feature request related to a problem? Please describe.
We should change rename the current sum function to be called total and create a new sum function that takes four parameters such as start index, end index, index variable, function.

This new sum function could have optimizations such as the sum of [0,n] or [1,n] is known to be n * (n - 1)/2.

Simplification Normalization Order

Ideally an equation like (x^4) + (x^6) + (x^2) + (x^5) + x + (x^3) should be automatically
reordered so that it looks like x^6 + x^5 + x^4 + x^3 + x^2 + x.

Additional Derivatives

Is your feature request related to a problem? Please describe.
Functions such as rad,deg,max,min,gcd,lcm,bounded, gamma, and ! do not have derivatives.

Describe the solution you'd like
Explore adding derivatives for these functions and operators.

Tokenizer Bug

The expression 1/2x currently evaluates to 1 / 2 x * but this is invalid postfix notation.
There are two ways of expressing this expression.

  1. 1 2 / x * ie (1 / 2) * x
  2. 1 2 x * / ie 1 /(2x)

Merge Post Simplify and Pre Simplify features into AST.Simplify

Is your feature request related to a problem? Please describe.
Currently the simplification code is spread across Post Simplify, Pre Simplify, and AST Simplify.
AST Simplify is the most powerful of the the simplification tools due to the fact that manipulating graphs is inherently easier than manipulating a list in postfix.

Describe the solution you'd like
Document all the functionality in Post Simplify and Pre Simplify and add that functionality into AST Simplify.

Additional context

Time results for derivative(cos(x)sin(x),x)

Type Time (ms) Ticks % Milliseconds % Ticks
Tokenize 4 45,187 1.87 2
PreSimplify 0 8,959 0 0
Shunting 51 519,387 23.83 24
PostSimplify 71 714,023 33.18 33
AST Generate 0 15 0 0
AST Simplify 17 175,355 7.94 8
AST Generate 0 21 0 0
AST MetaFunctions 36 363,379 16.82 17
AST Simplify 35 353,184 16.36 16
Evaluation 0 348 0 0
Total 214 2,179,858

Decimal number bug

Describe the bug
When a user enters a number such as -.5 implicit multiplication is performed.
Current behavior
RPN: -. 5 *

Expected behavior
RPN: -.5

Constant multiplication bug

Describe the bug
A constant such as pi or e multiplied by a number like this pi(3) results in incorrect RPN.
Current behavior
RPN: 3 pi
Expected behavior
RPN: 3 pi *

Symbolic Integration

Is your feature request related to a problem? Please describe.
There should be a way to create symbolic integration for a subset of integrations.
The integration(x^2,x,0,100) takes one second to calculate even though its integration is a very simple.

Describe the solution you'd like
When a user types in integration for a subset of integrations the program should return the derivative and then analyze it at the start and end points.
integration(f(x),x) -> F(x) + c
integration(f(x),x,a,b) -> F(b) - F(a)

The integrate command should take two arguments and be internal only. It should denote that an item has yet to be integrated by the program. If there is no applicable integration is available then the library should fall back to approximating a function.

The at command should take three arguments and be internal only.
at(f(x),x,c)

Describe alternatives you've considered
Currently the program does mathematical integration by using the Simpson's rules alongside the Midpoint approximation methods. The program attempts to calculate the integral in this method but it can take a very long time for very simple integrations. This implementation should be fall back in the event no applicable integration rule is found.

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.