Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
javascript Solving equation with subsitution of variable value

I am trying to use the nerdamer library to solve equation. Following is example which works: //multiple roots

var y = nerdamer.solve('x^6+41*x^5+652*x^4+5102*x^3+20581*x^2+40361*x+30030', 'x');
console.log(x4.toString());

But I want to solve with expression containing constant variable calculated already. For example:

var y= nerdamer.solve('x^6+a*x^5+652*x^4+b*x^3+20581*x^2+40361*x+30030', 'x');

where a and b have already been calculated in javascript code above this expression.

How can I do it? is it possible to convert terms into strings and concatenate?

thank you

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There are many ways to do this, you could use string concatenation:

var y= nerdamer.solve('x^6+' + a + '*x^5+652*x^4+' + b + '*x^3+20581*x^2+40361*x+30030', 'x');

Or Template literals to allow for variable substitution:

var y= nerdamer.solve(`x^6+${a}*x^5+652*x^4+${b}*x^3+20581*x^2+40361*x+30030`, 'x');
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!