Standard formula for solving simultaneous equations of the form ax + by + c = 0

In summary, the user is working on a computational geometry problem involving basis vectors and needs to solve a system of equations. They have found a formula for the solution, but it does not match the answers given by two solver applications. The user is looking for help in determining the correct formula for this type of system.
  • #1
LMHmedchem
20
0
Hello,

This algorithm overall is probably more complicated than is correct for the pre-university forum but this question is about a relatively simple aspect of the calculations so I hope that this will be the proper place to ask.

I am writing a little program to do some computational geometry calculations and find I need to do an operation with basis vectors. This involves solving the following system of equations.

$$ ( \vec {BA} \cdot \vec {BE} ) = s ( \vec {BA} \cdot \vec {BA} ) + t ( \vec {BA} \cdot \vec {BD} ) $$
$$ ( \vec {BD} \cdot \vec {BE} ) = s ( \vec {BD} \cdot \vec {BA} ) + t ( \vec {BD} \cdot \vec {BD} ) $$

Setting aside that these are vectors, the dot products are scalar, so to my eye this just looks like a pair simple system of,
$$ c = ax + by $$
$$ f = dx + ey $$
or in the form,
$$ ax + by + c = 0 $$
$$ dx + ey +f = 0 $$

Unless I am incorrect about this, I am looking for a formula to solve this system for x and y. A solution for simultaneous equations by substitution can be difficult to code because the algebraic manipulation varies depending on the form of the equations. In this case, the above form is the only one I have to deal with, so there should be a simple formula to determine x and y for the above case. I don't want to use a matrix so I have looked a bit for other solutions.

I found a post that gave the following for the solution,
$$ x = (fb-ce)/(ae-db) $$
$$ y = (cd -fa)/(ae-db) $$

I have a test case with the following data,
Code:
a = 7.0215
b = -1.7246
c = 0.5162
d = -1.7246
e = -0.8249
f = 0.0736
and the above formulas give me the answer,
Code:
x = -0.034094599
y = 0.160503753

This does not agree with two solver applications that both give,
Code:
x = -0.196163
y = 0.499336

I don't know if the formula I used is incorrect of if I applied it incorrectly. There should be a simple formula for a system in this form, but I don't really know where to look for such things.

Suggestions would be appreciated,

LMHmedchem
 
Mathematics news on Phys.org
  • #2
LMHmedchem said:
Hello,

This algorithm overall is probably more complicated than is correct for the pre-university forum but this question is about a relatively simple aspect of the calculations so I hope that this will be the proper place to ask.

I am writing a little program to do some computational geometry calculations and find I need to do an operation with basis vectors. This involves solving the following system of equations.

$$ ( \vec {BA} \cdot \vec {BE} ) = s ( \vec {BA} \cdot \vec {BA} ) + t ( \vec {BA} \cdot \vec {BD} ) $$
$$ ( \vec {BD} \cdot \vec {BE} ) = s ( \vec {BD} \cdot \vec {BA} ) + t ( \vec {BD} \cdot \vec {BD} ) $$

Setting aside that these are vectors, the dot products are scalar, so to my eye this just looks like a pair simple system of,
$$ c = ax + by $$
$$ f = dx + ey $$
or in the form,
$$ ax + by + c = 0 $$
$$ dx + ey +f = 0 $$

Ok, you just changed the equations here. The system
\begin{align*}
ax+by+c&=0 \\
dx+ey+f&=0
\end{align*}
is consistent with
\begin{align*}
ax+by&=-c\\
dx+ey&=-f,
\end{align*}
not what you had. The solution to
\begin{align*}
ax+by&=c\\
dx+ey&=f,
\end{align*}
which is your original system, assuming $s=x, y=t, BA\cdot BE=c, BA\cdot BA=a, BA\cdot BD=b, BD\cdot BE=f, BD\cdot BA=d,$ and $BD\cdot BD=e$, is
\begin{align*}
x&=\frac{bf-ce}{bd-ae} \\
y&=\frac{cd-af}{bd-ae},
\end{align*}
assuming, of course, that $bd-ae\not=0$. What does that give you?
 
  • #3
I was not sure I was posting this and there doesn't seem to be a way to delete it.
 
Last edited:
  • #4
Erm... did this solve the ambiguity? Is everything as expected now?
 
  • #5
I like Serena said:
Erm... this did solve the ambiguity? Or is everything as expected now?
I think so, but I need to do a few things before I can complete my reply.

Thanks
 
  • #6
I am going to re-write the entire problem now because I think I made some errors in my original post. I apologize for the post being long, but I think it is best to do these problems out completely for the benefit of others who may be reading along.

For the following original data,
Code:
id   x          y          z
B   -0.39467   -0.09908   -0.61004
A    1.90877    1.16538   -0.26828
D   -0.67216   -0.83449   -1.06511
E   -0.70794    0.02001   -0.44984

We take vectors from point B to points A, D, and E,
$$\vec{BA} = ( 2.30344, 1.26446, 0.34175)$$
$$\vec{BD} = (-0.27750, -0.73541, -0.45507)$$
$$\vec{BE} = (-0.31328, 0.11918, 0.16019)$$

To solve the system,
$$ ( \vec{BA} \cdot \vec {BE} ) = s ( \vec {BA} \cdot \vec {BA} ) + t ( \vec {BA} \cdot \vec {BD} ) $$
$$ ( \vec {BD} \cdot \vec {BE} ) = s ( \vec {BD} \cdot \vec {BA} ) + t ( \vec {BD} \cdot \vec {BD} ) $$

which is a system in the form,
$$ ax + by = c $$
$$ dx + ey = f $$
where s=x and t=y

To solve, we calculate the dot products and assign to their respective variables,
I didn't include the calculations for this because this is not a linear algebra forum.
$$ \vec{BA} \cdot \vec {BA} = 7.02147 = a $$
$$ \vec{BA} \cdot \vec {BD} = -1.72462 = b $$
$$ \vec{BA} \cdot \vec {BE} = -0.51617 = c $$
$$ \vec{BD} \cdot \vec {BA} = -1.72462 = d $$
$$ \vec{BD} \cdot \vec {BD} = 0.82492 = e $$
$$ \vec{BD} \cdot \vec {BE} = -0.07361 = f $$
$$ \vec{BA} \cdot \vec {BD} = \vec{BD} \cdot \vec {BA}, b = d $$

and substitute into the form described above,
$$ ax + by = c $$
$$ 7.02147x + (-1.72462y) = -0.51617 $$
$$ dx + ey = f $$
$$ -1.72462x + 0.82492y = -0.07361 $$

solve ax + by = c for x in terms of y

reverse the sign of "by" and add to both sides
$$ ax + by = c $$
$$ ax + by + (-by) = c + (-by) $$
$$ ax = c + (-by) $$
for this case,
$$ 7.02147x + (-1.72462y) + 1.72462y = -0.51617 + 1.72462y $$
$$ 7.02147x = -0.51617 + 1.72462y $$

divide both sides by "a"
$$ \frac{ax}{a} = \frac{c - by}{a} $$
$$ x = \frac{c - by}{a} $$
$$ x = \frac{c}{a} -\frac{by}{a} $$
for this case,
$$ \frac{7.02147x}{7.02147} = \frac{-0.51617 + 1.72462y}{7.02147} $$
$$ x = \frac{-0.51617 + 1.72462y}{7.02147} $$
$$ x = \frac{-0.51617}{7.02147} + \frac{1.72462y}{7.02147} $$
$$ x = -0.07351 + 0.24562y $$

substitute solution for x in terms of y to dx + ey = f
$$ dx + ey = f $$
$$ d( (\frac{c}{a})-(\frac{by}{a}) ) + ey = f $$
for this case,
$$ -1.72462(-0.07351 + 0.24562y) + 0.82492y = -0.07361 $$

distribute d
$$ d(\frac{c}{a}) - d(\frac{by}{a}) + ey = f $$
for this case,
$$ -1.72462(\frac{-0.51617}{7.02147}) - (-1.72462(\frac{1.72462y}{7.02147})) + 0.82492y = -0.07361 $$
$$ 0.12678 - \frac{2.97431y}{7.02147} + 0.82492y = -0.07361 $$
$$ 0.12678 + -0.42360y + 0.82492y = -0.07361 $$
$$ 0.12678 + 0.40132y = -0.07361 $$
$$ 0.12678 + (-0.12678) + 0.40132y = -0.07361 + (-0.12678) $$
$$ 0.40132y = -0.20039 $$
divide both sides by the coefficient of y
$$ \frac{0.40132y}{0.40132} = \frac{-0.20039}{0.40132} $$
$$ y = \frac{-0.20039}{0.40132} $$
$$ y = -0.49932 $$

substitute -0.49932 for y in ax + by = c
$$ ax + b(-0.49932) = c $$
for this case,
$$ 7.02147x + (-1.72462(-0.49932)) = -0.51617 $$
$$ 7.02147x + 0.86113 = -0.51617 $$
$$ 7.02147x + 0.86113 + (-0.86113) = -0.51617 + (-0.86113) $$
$$ 7.02147x = -0.51617 + (-0.86113) $$
$$ 7.02147x = -1.3773 $$
divide both sides by the coefficient of x
$$ \frac{7.02147x}{7.02147} = \frac{-1.3773}{7.02147} $$
$$ x = \frac{-1.3773}{7.02147} $$
$$ x = -0.19616 $$

The solution,
$$ x = s =-0.19616 $$
$$ y = t = -0.49932 $$

checks in both equations,
$$ 7.02147x + -1.72462y = -0.51617 $$
$$ 7.02147(-0.19616 )+ -1.72462(-0.49932) = -0.51617 $$
$$ -1.72462x + 0.82492y = -0.07361 $$
$$ -1.72462(-0.19616) + 0.82492(-0.49932) = -0.07361 $$

The solution also agrees with the formula posted by https://mathhelpboards.com/pre-algebra-algebra-2/standard-formula-solving-simultaneous-equations-form-ax-c-0-a-24260-post108353.html#post108353
$$ x = (bf-ce)/(bd-ae) $$
$$ y = (cd -af)/(bd-ae) $$
and also agrees with a calculator program.

As you can see above, I was not really able to generalize the algebra after "distribute d" and so was not able to arrive at the solution posted by Ackbach by my own proof.

If someone could walk me through that part, that would complete my understanding, otherwise, thank you for getting me to this point.

LMHmedchem
 

Related to Standard formula for solving simultaneous equations of the form ax + by + c = 0

What is the standard formula for solving simultaneous equations of the form ax + by + c = 0?

The standard formula for solving simultaneous equations of the form ax + by + c = 0 is:
x = (c1b2 - c2b1)/(a1b2 - a2b1)
y = (a1c2 - a2c1)/(a1b2 - a2b1)
Where a1, b1, c1 and a2, b2, c2 are the coefficients of x and y in each equation.

What is the reasoning behind this formula?

This formula is derived from the method of substitution, where one variable is isolated in one equation and then substituted into the other equation. By substituting the value of one variable into the other equation, we can solve for the remaining variable.

Can this formula be used for any type of simultaneous equations?

No, this formula can only be used for linear simultaneous equations of the form ax + by + c = 0. It cannot be used for equations with higher degree terms or for systems of equations with more than two variables.

Are there any limitations to using this formula?

This formula may not work if the denominators in the equations are equal to 0, as division by 0 is undefined. Additionally, if the coefficients of x and y are very large or small, there may be issues with precision and accuracy in the solution.

Are there any alternative methods for solving simultaneous equations?

Yes, there are several other methods for solving simultaneous equations, such as graphing, elimination, and substitution. The best method to use will depend on the specific equations and variables involved.

Similar threads

  • General Math
Replies
11
Views
2K
Replies
10
Views
2K
  • Introductory Physics Homework Help
Replies
3
Views
406
Replies
2
Views
652
  • General Math
Replies
6
Views
2K
  • Calculus and Beyond Homework Help
Replies
4
Views
929
  • Classical Physics
Replies
3
Views
1K
  • Introductory Physics Homework Help
Replies
1
Views
568
  • Introductory Physics Homework Help
Replies
25
Views
454
Back
Top