15,743,179 members
See more:
i have being wondering how to solve simultaneous equation in javascript using only one input field, to set the equation like this 2x + 3y + 8 = 0 and solve it without using three input field,but i can,t still figure it out i need help,i don't really know if this question is accepted here but i need an answer please

What I have tried:

i have google it out but no solution yet
Posted
Updated 6-Feb-21 20:43pm
[no name] 3-Apr-17 13:17pm
You are looking for an expression parser.
ZurdoDev 3-Apr-17 13:58pm
You'll have to break out the pieces. Not an easy thing to do.
please can you tell me how to break it out in pieces or refer me to a site were i can read about it,i don't care how hard it is i am willing to learn.

Solution 1

First restrict yourself to solving something like:
(user input) Ax + By = C (use only 'x' and 'y' for variables to solve)
Remove all spaces so that you get:
Ax+By=C (this makes parsing easier since any MINUS in (Ax - By = C) becomes part of the coefficient)
Use the equivalent of (C function) strchr() to search for 'x' then 'y' and then '=' to get the values of A, B & C respectively (of course you will have to convert the ascii values of digits to plain numeric - your own atoi() or atof()).

You can then use determinants to solve. The following is just one link that provides step by step details - search google determinant equation 2X2:
"Determinants and Cramer's Rule for 2x2 Systems 1 | Coolmath.com[^]