algebra.js icon indicating copy to clipboard operation
algebra.js copied to clipboard

Divide with expressions?

Open viktorstrate opened this issue 7 years ago • 5 comments

Could it be possible to make expressions dividable with other expressions. Eg

new Expression(1).divide(new Expression('x'))

If I try this now I get

TypeError: Invalid Argument (x): Divisor must be of type Fraction or Integer.

And make variables remove them self, like this

var upper = new Expression('x').multiply(2)
var lower = new Expression('x').multiply(4)

var result = upper.divide(lower) // expected result: 1/2

Edit: replaced .add() with .multiply(), thanks @Benjadahl

viktorstrate avatar Mar 20 '17 19:03 viktorstrate

I guess no! As of now division of expressions with expressions is not implemented!

pvskand avatar Mar 20 '17 19:03 pvskand

Note: (2 + x)/(4 + x) != 1/2

It would be (2 * x)/(4 * x)

Unless I am terribly bad at math :P

Benjadahl avatar Apr 08 '17 11:04 Benjadahl

You're right my bad, I've updated the original post.

viktorstrate avatar Apr 08 '17 17:04 viktorstrate

Facing same issue. Any update on this?

KhubaibQaiser avatar Apr 24 '18 06:04 KhubaibQaiser

I have this implemented to a certain extent, although I'm not actively working on it. Check it out here: https://github.com/yodadude2003/algebra.js

IsaMorphic avatar Mar 11 '19 14:03 IsaMorphic