- #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,
and the above formulas give me the answer,
This does not agree with two solver applications that both give,
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
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
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