Code Monkey home page Code Monkey logo

nerdamer's People

Contributors

alienkevin avatar amydevs avatar brosnanyuen avatar douglasdemoura avatar gksander avatar happypig375 avatar jiggzson avatar kungfooman avatar ljacqu avatar menzelths avatar msafronov avatar muhammadabdelsalam avatar n00bie-to-github avatar naridal avatar phcreery avatar saikedo avatar selairi avatar tecosaur avatar vojtechjelinek avatar yaffle avatar yosuke avatar yuliapi 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nerdamer's Issues

Ceiling function it's not being parsed

I've tried on demo and in the javascript console:

var e = nerdamer('ceiling(2.4)', null, 'numer');
console.log(e.text());
//returns ceiling(2.4), expected 3

It's not working. I didn't detect the issue on the code. Maybe you guys can take look?

Wrong sinus calculation

Hi, I don't know if that't my bad or nerdamer mistake, but sin(x) looks like sin(abs(x))...

npm issue

Hello, i am using nerdamer in my serverside application.
When i try to use diff function i get error

_nerdamer2.default.diff is not a function

nerdamer.reserved() shows
csc, sec, cot, erf, fact, mod, GCD, PI, E, cos, sin, tan, acos, asin, atan, exp, min, max, floor, ceiling, round, vector, matrix, parens, sqrt, log, abs, invert, transpose, dot

version 0.5.7

import:
import nerdamer from 'nerdamer'

usage:
let diff = nerdamer.diff(funcY)

How can i use diff function in my case?

buildFunction

Extend buildFunction for functions outside the core.

Auto-detect and register new functions

I believe that would be better if nerdamer could detect and register custom functions. Like this:

if(/([a-z])\([a-z](.*)\)=/i.test(input)) {
  var fn = input.match(/[a-z]+\(/i)[0].replace('(', '');
  var exp = input.split('=')[1];
  var arguments = input.replace(fn, '').replace(exp, '').replace('=', '').replace('(', '').replace(')', '').split(',');
  nerdamer.setFunction(fn, arguments, exp);
}

It worked fine with the functions below:

  • hyp(a, b) = sqrt(a^2 + b^2)
  • f(x) = x^2

Sorry for not sending a pull request, I'm just an amateur.

Weird results with sqrt

Entering formulas like

sqrt(2x)

or

sqrt(2*x)

etc. give weird results like

√((3880899 x)/2744210)

nerdamer.solveEquation quits working

console.log(nerdamer.solveEquations("x+1=2", "x").toString())
console.log(nerdamer("x=1").text("fractions"))
console.log(nerdamer.solveEquations("x+1=2", "x").toString())

this logs an empty string for the third line

buildFunction doesn't handle built-in constants correctly.

nerdamer('pi * x').evaluate({x: 2}).text('decimals') // ~= 6.28
nerdamer('pi * x').buildFunction(['x'])(0) // ReferenceError: pi is not defined

The function body is just pi * x, and pi apparently isn't bound. I'd expect Math.PI to be used.

Manually doing nerdamer.setConstant('pi', Math.PI) fixes it, but that shouldn't be necessary.

As an aside, what's the deal with *? Sometimes it works, othertimes you get weird errors.

"(a-b)^2 - (b-a)^2" not simplifying.

On the input "(a-b)^2 - (b-a)^2", it doesn't simplify to 0. This could probably be fixed by always formatting expressions of type (±a ± b ± c ± ...)^2n so that 'a' has a positive coefficient (i.e 'a' doesn't have a minus sign in front).

buildFunction forgets brackets

const wtf = nerdamer('4 (s^2 + t^2) s').buildFunction(['s', 't']).toString()
// wtf ==
function anonymous(s,t
/*``*/) {
 return 4*(Math.pow(s,2)+Math.pow(t,2)*s); // s should be right of the bracket
}

Solving Equation problem

I am build a graphing system using your Library thanks a lot you made such a library helped me a lot but I am finding an issue in getting the value of y when that Equation is of the form below:

var equation = (x-1)^2 + (y-1)^2 - (4)

var val = nerdamer(equation, { x: 4});
var parse = val + "=0"; Where parse is "(-1+y)^2+5=0"

var sol = nerdamer.solveEquations(parse, 'y');

Error: From Algebra , Invalid array length as in the rpSolution function the degree parameter is coming up as NaN (not a number).

Please can you help me in this because I am looping though the value to get the value of 'y' to generate a circle.

The library is supporting the equation x^2 + y^2 =4, But if i am adding the center value then its not working example (x-1)^2 + (y-1)^2 - (4)

pi doesn't work in diff()

For example, derivative of x^2pi should be 2pix, but this lib will give a result x^2.
It seems that in diff() pi is not supported.

Get TeX string prior to evaluating?

Is there any way to parse a string to LaTeX using nerdamer prior to nerdamer evaluting the string? For example -- taking 'x*x' and returning 'x \cdot x' instead of 'x^2' ?

Failing tests

Hello, the result of the following tests has changed. Could I ask you to confirm that the new results are correct?

given: 'integrate(x*asin(x), x)',
expected: '(-1/4)*asin(x)+(1/2)*asin(x)*x^2+(1/4)*sqrt(-x^2+1)*x'
actual:   '(-1/4)*asin(x)+(1/2)*asin(x)*x^2+(1/4)*cos(asin(x))*sin(asin(x))'

given: 'integrate(q/((2-3*x^2)^(1/2)), x)',
expected: 'asin(sqrt(2)^(-1)*sqrt(3)*x)*q*sqrt(3)^(-1)'
actual:   'asin(3*sqrt(6)^(-1)*x)*q*sqrt(3)^(-1)'

given: 'integrate(x*(x+a)^3, x)',
expected: '((1/4)*x^4+(3/2)*a^2*x^2+a*x^3+a^3*x)*x+(-1/2)*a^2*x^3+(-1/2)*a^3*x^2+(-1/20)*x^5+(-1/4)*a*x^4'
actual:   '(1/2)*a^3*x^2+(1/5)*x^5+(3/4)*a*x^4+a^2*x^3'

given: 'integrate(8*x^3/(6*x^2+3*a^2), x)',
expected: '8*((-1/24)*a^2*log(3*a^2+x^2)+(1/12)*x^2)'
actual:   '8*((-1/24)*a^2*log(2*x^2+a^2)+(1/12)*x^2)'

given: 'integrate(log(a*x+b),x)',
expected: '((a*x+b)*log(a*x+b)-a*x-b)*a^(-1)'
actual:   '-x+a^(-1)*b*log(a*x+b)+log(a*x+b)*x'

given: 'integrate(t*log(x)^3,x)',
expected: '(-3*log(x)^2+6*log(x)+log(x)^3-6)*t*x'
actual:   '(-3*log(x)^2*x-6*x+6*log(x)*x+log(x)^3*x)*t'

given: 'integrate(5*x*e^(-8*a*x^2),x)',
expected: '(-5/16)*a^(-1)*e^(-8*a*x^2)*log(e)^(-1)'
actual:   '(-5/16)*a^(-1)*e^(-8*a*x^2)'

given: 'integrate((x+7)/(x+1)^3,x)',
expected: '(-1/2)*(1+x)^(-1)+(-1/2)*(1+x)^(-2)*(7+x)'
actual:   '(-1/2)*(1+x)^(-1)+(-7/2)*(1+x)^(-2)+(-1/2)*(1+x)^(-2)*x'

Integration

I stumbled upon this SO post, mentioning that there should be an integration branch.

Have you added symbolic integration, or is it only for polynomials? If not, I could try starting a basic implementation in the calculus add-on.

version 0.7.x

  • Handle assignment directly within the parser. This will hopefully allow for more solving options
  • Fix prefix operators
  • Force base functions to use bigNumber library. This may or may not be an option since this may be re-implementing certain built-in functions
  • Extend equality checking to all classes Frac > Symbol > Expression

(x+a)^n -> NaN

(x+3)^2 outputs NaN.
(x-(-3))^2 works.

same with 1/(x+3)

Solve fails to switch to algebraic method for quadratics and cubics

var x = nerdamer('solve(x^2+2*x+7,x)');
console.log(x.toString())
//[(209774887/85640239)*i-1,(-159018721/64919121)*i-1]

The numeric solution is returned. Nerdamer is perfectly capable of returning the algebraic solution for univariate polynomials and should make this its first option.

Get results in a decimal form

Is it possible to make the LaTeX generator return the decimal value instead of the fraction?

3/10 = 0.3 instead of 3/10

I know that we will face a floating point issue (because the result will be 0.30000000000000004). Perhaps add a BigDecimal library to handle it?

Euler's identity

var e = nerdamer('e^(2*i*PI) +e^(i*PI)');
console.log(e.text());

e^(3.141592653589793_i)+e^(6.283185307179586_i)

Euler's identity could be useful in solving complex exponential. (E.g (a+bi)^n )

Latex generator broken

When the expression is requested as latex, often brackets aren't added when there should be. For example when the expression has a non-unit multiplier or power. This issue is strictly related to the latex generator as expression values are correct when the text method is called.

bitwise operators?

Does this library support bit shifting and bitwise operators?
As this is something I can really use :)

Thanks

nerdamer("x^2+x+1").latex() = "x+x^2+1"

In the new version, the order of polynomials is changed in the LaTeX output. I would expect the following result:

nerdamer("x^2+x+1").latex() = "x^2+x+1"

Can the LaTeX output optionally again be switched to the old style?

Symbol evaluate() method

I see that the Symbol prototype does not have an evaluate method, but the master nerdamer function has an option to evaluate by passing an object. Is there currently a way to evaluate a Symbol object in a similar way, by passing an object with variable-value pairs?

As an explicit example, if I get a Symbol object returned from the integrate function, is there currently a way to evaluate that Symbol at a numerical value?

Multiple minus operators yield wrong result

I just noticed that multiple - (and brackets) don't seem to get along in some cases. Here are two failing test cases.

{
   given: '-(1)--(1-1--1)',
   expected: '0'  // current result: -2
},
{
   given: '-(-(1))-(--1)',
   expected: '0'  // current result: 2
}

Circle Equations

The library has helped me a lot in building a graphing system, I am stuck at one place , Can you people design a way where if I can detect any equation of the form (x-a)^2 + (x-b)^2 = r^2 (i.e. is a generalized circle equation) and can let me know that its a circle (i.e. I want to know if any user types in this type of circle equation i want to know its a circle )

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.