Of the syntax you used to state the problem and the syntax in your sample input, I'm not sure which makes the least sense.
You could be helpful and explain your problem better. Using sentences. Right now, I'm thinking that _maybe_ you're trying to solve a three-by-three linear system. And "2 *= x -= 3 *= y = == 4" makes no sense whatsoever.
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 176
And what is "2 *= x -= 3 *= y = == 4" suppose to mean? This is completely nonsensical notation.
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 176
It's not impossible to solve the system of three equations with three unknowns using C/C++ but it isn't trivial either. The options to do it using a computer running a program written in C/C++ would be essentially the same as if you were doing it by hand, with the syntax adjusted as appropriate for the computer language as opposed to the mathematical language. Is there a standard function/library you could use to do this? I doubt it very much. Could you write your own? Sure, but it's going to require a lot of work. Could you scour the internet and find a third party library to do it for you? Quite possibly. I'm sure somebody has converted the pen and paper process into C/C++, but whether you'll be able to find a version of that program/algorithm on the internet is open to speculation, and it's not likely someone here is going to write this type of program for you.
No matter how you do it, at some point you will likely need some mechanism to separate the variable coefficients from the variables per se'. Depending on your restaints, you could ask the user to input this data for you or you could accept the equations as strings and parse out the various system variables, coefficients, and constants.
Once you have the vrarious coefficients, variables, and constants isolated, you probably already know that you can solve this type of system of equations using
1) linear algebra and matrixes or
2) isolate x in terms of y and z using equation 1, then y in terms of z in equation 2, and finally solve for z using equation 3 and the appropriate substitutions or
3) some other technique.
Once you've devised ways to isolate the information needed and determined the algorithm you are going to use, then you can start thinking about how to write the code.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
To find values x, y, z for equations
ax + by + cz = r
dx + ey + fz = s
gx + hy + iz = t
Youcould use the formulas
x = (e*i - f*h) * r / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) - (b*i - c*h) * s / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) + (b*f - c*e)*t/(g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)
y = -(-g*f + d*i)*r / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) + (-g*c + a*i)*s / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) - (-d*c + a*f)*t / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)
z = (-g*e + d*h)*r / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h) - (-g*b + a*h)*s / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)+( - d*b + a*e)*t / (g*b*f - g*c*e - d*b*i + d*c*h + a*e*i - a*f*h)
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 176