Author Topic: Simplifying an equation  (Read 1721 times)

0 Members and 1 Guest are viewing this topic.

Offline bja888

  • Flagrunner
  • ****
  • Posts: 745
  • Working
    • Bja888.com
Simplifying an equation
« on: October 17, 2009, 06:55:58 pm »
I seem to recall that some members of the forums are rather handy with their math skills. I am not sure if they are still around but I hoping someone can help me with this. I need a equation simplified and for some reason I cant recall how do do it from my math classes 5 years ago... (wonder why?)

So here it is....
( sqrt( (Rx-x)^2 + (Ry-y)^2 ) / sqrt( (Tx-x)^2 + (Ty-y)^2 ) ) = o

I need it in "x =" form. I need to find the intersection of that funky shape with a line.
y = m(x + Tx) + Ty

So, I guess I need it like this.
( sqrt( (Rx-x)^2 + (Ry-(m(x + Tx) + Ty))^2 ) / sqrt( (Tx-x)^2 + (Ty-(m(x + Tx) + Ty))^2 ) ) = o

There are 3 points here T, R and the point I am solving for. T, R, o and m are going to be known. I just need x and y. (aka L)

Now I am sure the first 5 posts are gonna be people asking me what its for...
This is a formula to predict the collision of 2 objects moving at separate speeds. Attached is an image of what this is going to look like when finally coded. R is the object that I am trying to hit. A projectile is going to be launched from T. Assuming R does not change velocity and I know the speed of the projectile, they will hit at point L.
Also attached is the CaRMetal file I am working with. It works, try moving the points.

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Simplifying an equation
« Reply #1 on: October 17, 2009, 07:50:52 pm »
I may be reading into this wrong, but why wouldn't you just check for the intersection of the two line segments made by the moving objects (their pos last update -> current pos)? That doesn't require roots or fancy (slow) stuff like that.

Offline bja888

  • Flagrunner
  • ****
  • Posts: 745
  • Working
    • Bja888.com
Re: Simplifying an equation
« Reply #2 on: October 17, 2009, 07:58:46 pm »
The TL line cant be made till you know where L is. And there is another dimension not shown on the graph, time. I probably did not do a good job explaining it. I am going to go into much more detail when I explain it on my blog. But for now, I just need it simplified.

Offline Smegma

  • Inactive Staff
  • Soldier
  • *****
  • Posts: 131
  • That's just a way to break a unity
Re: Simplifying an equation
« Reply #3 on: October 18, 2009, 12:45:36 am »
Alright, I wasn't seeing the subscripts until I viewed the picture. Anyway, I just got back from a bar and I didn't feel like simplifying it too much. I did solved the first eqn for x (I think, I hope its correct). I cleaned up what I could in my head, but that may have just caused more mistakes. All I did was simply complete the square.

There is probably a much easier way, but f**k it.

Here it is:
« Last Edit: October 18, 2009, 12:47:20 am by Smegma »

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Simplifying an equation
« Reply #4 on: October 18, 2009, 12:48:16 am »
I mean more like this:

Offline Smegma

  • Inactive Staff
  • Soldier
  • *****
  • Posts: 131
  • That's just a way to break a unity
Re: Simplifying an equation
« Reply #5 on: October 18, 2009, 12:55:36 am »
Realized a small error, among what might be large ones.

new and improved eqn:



realized you wanted the third. It'll be longer, working on it.




eqn 3, simplified. Probably not, but well...I dont even want to go back through my work to check for errors.
« Last Edit: October 18, 2009, 01:39:39 am by Smegma »

Offline bja888

  • Flagrunner
  • ****
  • Posts: 745
  • Working
    • Bja888.com
Re: Simplifying an equation
« Reply #6 on: October 18, 2009, 02:35:13 am »
I converted the whole damn thing before I realized there is a problem. The 3rd equation is the one I need simplified, but I typed it wrong.

Correct equation to simplify.
( sqrt( (Rx-x)^2 + (Ry-(m(x - Tx) + Ty))^2 ) / sqrt( (Tx-x)^2 + (Ty-(m(x - Tx) + Ty))^2 ) ) = o

I appreciate your help thus far.


eqn 3, simplified. Probably not, but well...I dont even want to go back through my work to check for errors.

My god.  I am probably gonna need to break it down to several smaller equations. Perhaps there is a better way?
« Last Edit: October 18, 2009, 03:26:57 am by bja888 »

Offline Smegma

  • Inactive Staff
  • Soldier
  • *****
  • Posts: 131
  • That's just a way to break a unity
Re: Simplifying an equation
« Reply #7 on: October 18, 2009, 09:27:03 am »
I converted the whole damn thing before I realized there is a problem. The 3rd equation is the one I need simplified, but I typed it wrong.

Correct equation to simplify.
( sqrt( (Rx-x)^2 + (Ry-(m(x - Tx) + Ty))^2 ) / sqrt( (Tx-x)^2 + (Ty-(m(x - Tx) + Ty))^2 ) ) = o

I appreciate your help thus far.


eqn 3, simplified. Probably not, but well...I dont even want to go back through my work to check for errors.

My god.  I am probably gonna need to break it down to several smaller equations. Perhaps there is a better way?

Well, I basically got it to look like x = sqrt ((c/a + b^2/a^2))-b/a; then just plugged in what I substituted for.

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: Simplifying an equation
« Reply #8 on: October 18, 2009, 01:49:03 pm »
what about asking your teacher? :3

Offline bja888

  • Flagrunner
  • ****
  • Posts: 745
  • Working
    • Bja888.com
Re: Simplifying an equation
« Reply #9 on: October 18, 2009, 11:13:28 pm »
I'm the one coming home from the bar tonight. I'll try to make since of things when I sober up a little more. I wanna thank you again for all your help.

From: October 19, 2009, 07:35:15 am
Thats a negative. Does not work.

Code: [Select]
In [36]: run forumla-test.py
math.sqrt( (-76.0/-2.0) + (-8.0**2)/(2*(-2.0**2)) ) - -8.0/(2*-2.0)
(4.78232998313, -2.78232998313)
Fail!


Code: (python) [Select]

import math

class point():
x = 0.0
y = 0.0
def __init__(self, ex, why):
self.x = ex
self.y = why

global R, T, m, o

R = point(1.0, 5.0)
T = point(1.0, 1.0)
m = -1.0/1.0
o = 1.0

def main():
ex = testFormula(R, T, o, m)
why = lineFormula(ex, T, m)
print('(%s, %s)' % (ex, why))
if ex != 3.0 and why != 3.0:
print('Fail!')

def testFormula(arrr, tee, ooo, mmm):
def fa():
return (mmm**2) - 1 - (ooo**2)*(1+(mmm**2))
def fb():
return arrr.x + mmm*arrr.y - (mmm**2)*tee.x + mmm*tee.y + (ooo**2)*tee.x + (ooo**2)*mmm*tee.y - (mmm**2)*tee.x*(ooo**2) + mmm*tee.y*(ooo**2) ## image version
#return arrr.x + mmm*arrr.y + (mmm**2)*tee.x + mmm*tee.y + (ooo**2)*tee.x + (ooo**2)*mmm*tee.y + (mmm**2)*tee.x*(ooo**2) + mmm*tee.y*(ooo**2)
def fc():
return ((ooo**2) * ((tee.x**2) + (tee.y**2) - 2.0*(mmm**2)*(tee.y**2) + 2.0*(tee.y**2) + (mmm**2)*(tee.x**2) - 2.0*mmm*(tee.y**2) + (tee.y**2))) - ( (arrr.y**2) - 2.0*mmm*tee.y*arrr.y + 2.0*arrr.y*tee.y + 2.0*arrr.y*tee.y - 2.0*mmm*tee.x*tee.y - (tee.y**2) + (arrr.y**2) + (mmm**2)*(tee.x**2)) ## image version
#return ((ooo**2) * ((tee.x**2) + (tee.y**2) + 2.0*(mmm**2)*(tee.y**2) + 2.0*(tee.y**2) + (mmm**2)*(tee.x**2) + 2.0*mmm*(tee.y**2) + (tee.y**2))) - ( (arrr.y**2) + 2.0*mmm*tee.y*arrr.y + 2.0*arrr.y*tee.y + 2.0*arrr.y*tee.y + 2.0*mmm*tee.x*tee.y + (tee.y**2) + (arrr.y**2) + (mmm**2)*(tee.x**2))

print('math.sqrt( (%(fc)s/%(fa)s) + (%(fb)s**2)/(2*(%(fa)s**2)) ) - %(fb)s/(2*%(fa)s)' % {'fa': fa(), 'fb': fb(), 'fc': fc()})
return math.sqrt( (fc()/fa()) + (fb()**2)/(2*(fa()**2)) ) - fb()/(2*fa())

def lineFormula(ex, tee, mmm):
return mmm * (ex - tee.x) + tee.y

if __name__ == "__main__":
main()

Any ideas? I'll put more brain power into the problem tomorrow.
« Last Edit: October 19, 2009, 07:48:27 am by bja888 »

Offline Smegma

  • Inactive Staff
  • Soldier
  • *****
  • Posts: 131
  • That's just a way to break a unity
Re: Simplifying an equation
« Reply #10 on: October 19, 2009, 03:02:14 pm »
I could've just had a sign error while writing the eqn.

Offline bja888

  • Flagrunner
  • ****
  • Posts: 745
  • Working
    • Bja888.com
Re: Simplifying an equation
« Reply #11 on: October 19, 2009, 05:21:11 pm »
I am gonna have to call in a favor on this one and see what Mathematica can do with it.
http://www.wolfram.com/products/mathematica/index.html

From: October 20, 2009, 01:37:05 am
Well... Here is another long equation to test. Looks promising. One thing I was wondering about in your equations is why there was no + or - part. Since it is a line through a circle-like shape, there should be 2 points of intersection.
Now the hard part...
« Last Edit: October 20, 2009, 01:37:05 am by bja888 »

Offline Smegma

  • Inactive Staff
  • Soldier
  • *****
  • Posts: 131
  • That's just a way to break a unity
Re: Simplifying an equation
« Reply #12 on: October 20, 2009, 06:19:21 pm »
That's because im lazy and not paying attention.

Offline Snake

  • Soldier
  • **
  • Posts: 178
  • Chu Canadien Criss!
Re: Simplifying an equation
« Reply #13 on: October 20, 2009, 09:01:03 pm »
You may want to check wolframalpha.com and enter your equation there it will probably work

Offline HeavyMetal.Penguin91

  • Major(1)
  • Posts: 33
Re: Simplifying an equation
« Reply #14 on: October 30, 2009, 12:22:10 am »
Assuming I copied the original equation right, this is it rearraged in terms of x, in it's simplest form.

x = ( -B ± sqrt(B^2 - 4AC) ) / (2A)

A = (m^2 + 1)(o^2 -1)
B = 2( Rx + m(Ry + Ty + mTx) - o^2(Tx + 2mTy + m^2Tx) )
C = o^2Tx^2 - Rx^2 - Ry^2 + 3(Ty^2 - TyRy) + 2mTx(Ty - Ry)



Tell us if it works, because although I'm 100% sure that that's the right form of the equation, I might of made an error in the coefficients A,B & C.
(">

Offline bja888

  • Flagrunner
  • ****
  • Posts: 745
  • Working
    • Bja888.com
Re: Simplifying an equation
« Reply #15 on: November 02, 2009, 09:27:00 pm »
Yep, there was a flaw in the last one. I got it right this time. I'm not sure if it can be simplified though.

0 == ( Sqrt[(r - x)^2 + (s - (m (x - t) + s))^2] / Sqrt[(t - x)^2 + (u - (m (x - t) + s))^2]) - k

I am going to try to go about it another way.