Uncaught Error: Cannot convert "kg^4" to a number
var e = math.simplify(equation , { [p1]: (var2[0]), [p2]: (var2[1])
});
console.log(e);
return(e);
}
equation contains a dynamic equation like p1+p2 , p1-p2 or 5p1/4. Values of P1 and P2 are units like kg^2 , m^-4 etc. Any idea how can i resolve this issue?
Can you provide a minimal example demonstrating the issue?
OK. let suppose a user ha entered an equation to be solved. like equation = a + b. it can be any variable rather than a or b. these variables have values. like a = kg and b = kg^-1.
I want these units (kg and kg^-1) to be solved according to given equation. But the maths js library throws error for the above syntax. Can you help me with this?
var e = math.parse(equation , {
[p1]: (var2[0]),
[p2]: (var2[1])
});
console.log(e);
return(e);
}
The contents of the scope is taken as a value, not as an expression. I think you can evaluate your variables first too if they contain an expression?
contents of scope {p1 , p2} contains names of dynamic variables like a and b etc. Thats why I have to pass them as value. This case is working fine for arithmetic variables but is problematic in case of units.
can you give a concrete example? Maybe I can give you a concrete suggestion then :)