I am using Nerdamer.js and it works fine with the code, but when I am solving some equations, the result i get is a function instead of just numbers
here is an example:
1x³+2x²+3x-4=0
if you solve this equation you will get these values:
0.7760454350285384
1.7965885235495673
-1.7965885235495673
or sometimes just the first value
but when i try to solve it with Nerdamer, I will an array of 3 objects with some informations, and the answers in each object are:
(-1/3)*(-146+6*sqrt(606))^(1/3)*2^(-1/3)+(5/3)*(-146+6*sqrt(606))^(-1/3)*2^(1/3)-2/3 (1/6)*((-146+6*sqrt(606))^(1/3)*2^(-1/3))^(-1)*(-5+5*i*sqrt(3))+(1/6)*(-146+6*sqrt(606))^(1/3)*(1+i*sqrt(3))*2^(-1/3)-2/3 (1/6)*((-146+6*sqrt(606))^(1/3)*2^(-1/3))^(-1)*(-5-5*i*sqrt(3))+(1/6)*(-146+6*sqrt(606))^(1/3)*(-i*sqrt(3)+1)*2^(-1/3)-2/3 and here is my code:
let nerdamer = require('nerdamer');
require('nerdamer/Algebra.js');
require('nerdamer/Calculus.js');
require('nerdamer/Solve.js');
and this is how i get the values:
var sol = nerdamer.solveEquations('1x^3+2x^2+3x-4=0');
console.log(sol[0].toString());
console.log(sol[1].toString());
console.log(sol[2].toString());
You need to call .evaluate() for each solution.
var sol = nerdamer
.solveEquations('1x^3+2x^2+3x-4=0')
.map(solution => nerdamer(solution).evaluate().text())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With