Avotas

Ok .. I need to solve for F and A in this problem below. The question is how do you program that

Equation 1: 190 = (F/2) + A

Equation 2: 169 = ((F/2) ¨C A) * -1

BTW I worked it out with pen and paper (Substitution Method) the answers are:

F=21

A=179.5

Thx again guys ... been a really big help!

-Avotas




Re: Visual C# General Solving Systems of Linear Equations

Avotas



Anyone





Re: Visual C# General Solving Systems of Linear Equations

Peter N Roth

You can find the answer in pretty much any book that explains matrix math.

With only two equations, look up ˇ°determinantsˇ±.

For more than two, look up Gaussian decomposition.

For a zillion equations, it gets a little more specializedˇ­






Re: Visual C# General Solving Systems of Linear Equations

John.Doe

How to program something like this Easy enough:

First of all make the user enter the equation in a normalized form, e.g. for a equation with 3 variables:

a*x + b*y + c*z = d
e*x + f*y + g*z = h
i*x + j*y + k*z = l

where the user is asked for inputs a to l.

Then systematically eliminate variables:
take the first equation and eliminate "x" in all other equations, e.g. for the second equation by dividing all factors of equation 1 by a and multiplying them with e and substracting equation 1 from 2. Do that for the second equation and y afterwards and so forth... once you got the last variable value figured out, insert bottom up into the equations to get the rest.

Of course pay attention to entries of 0 for the user input and so forth, but that is an easy method of programming something like this... have fun...





Re: Visual C# General Solving Systems of Linear Equations

Mark Dawson

Hi Avotas,

are you looking how to solve linear equations in general, or just for the specific case you mentioned If it is just a specific case as above with the values always being 190 and 169 then:

190 = (F/2) + A

169 = ((F/2) - A) * -1

Then replacing 190 = X and 169 = Y:

A = (X + Y) / 2

Substituting back into equation 1 you get F = X - Y. So if you want to turn this into code it would be:

int x = 190;

int y = 169;

double a = (x + y) / 2;

double f = x - y;

Mark.