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

LMHmedchem
Messages
20
Reaction score
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
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?
 
I was not sure I was posting this and there doesn't seem to be a way to delete it.
 
Last edited:
Erm... did this solve the ambiguity? Is everything as expected now?
 
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
 
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
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
I'm interested to know whether the equation $$1 = 2 - \frac{1}{2 - \frac{1}{2 - \cdots}}$$ is true or not. It can be shown easily that if the continued fraction converges, it cannot converge to anything else than 1. It seems that if the continued fraction converges, the convergence is very slow. The apparent slowness of the convergence makes it difficult to estimate the presence of true convergence numerically. At the moment I don't know whether this converges or not.
Back
Top