0

I don't know how to solve the following linear equation with jQuery.

12.5x = 20 + x + (20 + x)/10 (Note that 12.5, 20, and 10 are numbers provided by user)

Is there a way in jQuery to get x? Thank you very much

thecodeparadox
  • 86,271
  • 21
  • 138
  • 164
Floppy88
  • 1,031
  • 3
  • 13
  • 31
  • You don't need jQuery, regular JavaScript would do just fine. What exactly are you having problems with? – Anthony Grist Aug 13 '12 at 09:16
  • This has nothing to do with jQuery or any other language. There are plenty of threads in the "related" section to your right disucssing this topic e.g. http://stackoverflow.com/questions/769/solving-a-linear-equation?rq=1. I think the problem you are facing is the underlaying maths, not the API/language... – DrColossos Aug 13 '12 at 09:17

1 Answers1

2

Your problem is purely related to Math

Assume you equation is of format:

ax = b + x + (c + x) / d;

Hence the solution is:

var x = (b * d + c) / (a * d - d - 1);

if b === c then, solution is:

var x = (b * d + b) / (a * d - d - 1);
Community
  • 1
  • 1
thecodeparadox
  • 86,271
  • 21
  • 138
  • 164