Skip to main content
GameDev.net gamedev.net
🔒 Locked

it's too hard

Started by tion80 Nov 6, 2004 at 7:26 PM 32 replies 4.4k views
Original Post
tion80
tion80
Hi guys, I'm making some tennis game. x-y+sqrt(x^2-2)-sqrt(y^2-2)=0 Can anyone solve above equation for x like "x=..."? [Edited by - tion80 on November 6, 2004 7:58:10 PM]
Haytil
Haytil
What's this have to do with tennis? If you explain why you have this equation, maybe there's an easier way to deal with it that you haven't seen.
tion80
tion80
here

this is it..

T-T...
brunogmd
brunogmd
You mean solve for x ?
Bruno B
tion80
tion80
Yes. sorry for my terrible writing.
NTense
NTense
I think its:

x = sqrt(y^2 + 4);

but really if you're asking for it to be solved, you should probably figure out how and why the equation is applied..
tion80
tion80
Wow .... what a simple answer ;>

well, I need the equation from which I could randomly generate proper x & y velocity to shoot the ball

and... what if the equation is

x-y+sqrt(x^2-2)-sqrt(y^2-3)=0 ?

x = sqrt(y^2 + 5) ?
tion80
tion80
Wow!!!!

It looks working hm.
Can you tell me where '-1' come from in that equation?

is it -3-(-2)??
tion80
tion80
x-y+sqrt(x^2-a)-sqrt(y^2-b)=0

Could you solve this equation as well?

This is exactly what I'd like to know.

What kind of mathmatic do you use?

Differential equation or something?



tion80
tion80
Thank you very much.

I should try that kind of program too.

thanks alot.
Dmytry
Dmytry
Quote:

x-y+sqrt(x^2-2)-sqrt(y^2-2)=0

x=y is one of solutions, damn.
y-y+sqrt(y^2-2)-sqrt(y^2-2)=0 is true.

Another solution might be x that have different sign...

As about hairy problem:
Quote:

x-y+sqrt(x^2-a)-sqrt(y^2-b)=0

Rearranging
x+sqrt(x^2-a)=y+sqrt(y^2-b)
so let z=y+sqrt(y^2-b)
so
x+sqrt(x^2-a)=z
x-z=-sqrt(x^2-a)
(x-z)^2=x^2-a // warning - there may get some more roots than needed...
x^2-2xz+z^2=x^2-a
-2xz+z^2=-a
-2xz=-a-z^2
2xz=a+z^2
x=(a+z^2)/(2*z)// only one root, must be right root unless there's no root at all.
then you can replace z by y+sqrt(y^2-b) back if you like. Nothing too hairy, nothing fancy, just algebra.

BTW. Working solutions is only x and y that
(x^2-a)>=0 and (y^2-a)>=0
_Vlad
_Vlad
Here's the method :

x-y+sqrt(x^2-2)-sqrt(y^2-2)=0
x^2-2 = ( sqrt(y^2-2)-x+y )^2
Developping the right-hand term we find a simple 2nd order equation in x :
ax^2 + bx + c = 0
delta = b^2-4*a*c
solutions
X1 = (-b+sqrt(delta))/2a
X2 = (-b-sqrt(delta))/2a

delta > 0 -> 2 real solutions
delta = 0 -> 1 real solution
delta < 0 -> 2 complex solutions

Sorry if I'm repeating someone.
Dmytry
Dmytry
Quote:
Original post by _Vlad
Here's the method :

x-y+sqrt(x^2-2)-sqrt(y^2-2)=0
x^2-2 = ( sqrt(y^2-2)-x+y )^2
Developping the right-hand term we find a simple 2nd order equation in x .......

and note that x^2 cancels out, that is , a=0 (it's why in my explanations there's no quadratic equation).

( sqrt(y^2-2)-x+y )^2 = x^2-2*x*(sqrt(y^2-2)+y)+(sqrt(y^2-2)+y)^2
and we get

x^2-2 = x^2-2*x*(sqrt(y^2-2)+y)+(sqrt(y^2-2)+y)^2
where grey text shows what can be removed. (and result is the same as with my prev. post, with z expanded back)
Kurioes
Kurioes
x-y+sqrt(x^2-a)-sqrt(y^2-b)=0

Mathematica:
Input: Solve[x - y + Sqrt[x^2 - a] - Sqrt[y^2 - b] == 0, x]
Output: x -> (ay+by-a*sqrt(y^2-b)+b*sqrt(y^2-b))/2b
(Which could be simplified)
Dmytry
Dmytry
My solution is
z=y+sqrt(y^2-b)
x=(a+z^2)/(2*z)
and it can be unrolled to
x=(a+(y+sqrt(y^2-b))^2)/(2*(y+sqrt(y^2-b)))

and my solution is pretty much equivalent to mathematica's one:
double a=7,b=5,y=16;double z=y+sqrt(y*y-b);//1 sqrt, 3 mult, 1 div, 2 add, 1subdouble x_my=(a+z*z)/(2*z);double x_mat=(a*y+b*y-a*sqrt(y*y-b)+b*sqrt(y*y-b))/(2*b);// 1 sqrt (with compiler optimizations), 6 multiplies , 1 division , 2 add, 2 subcout<<"my="<<x_my<<"  mathematica="<<x_mat<<endl; //same results on all testscout<<x_my-y+sqrt(x_my*x_my-a)-sqrt(y*y-b)<<endl; //test


also your sqrts might in fact be +-sqrts ...

[Edited by - Dmytry on November 8, 2004 12:54:31 PM]
Phillipe
Phillipe
K man this's just too easy...
We start off with this formula:
x-y+sqrt(x^2-2)-sqrt(y^2-2)=0
So, the first thing we'll do is to multiply both sides of the equation at the power of two (in order to disable the square roots), so we'll end up with this formula:
x^2-y^2+x^2-2-(y^2-2)=0
Let's just get rid of this brackets there:
x^2-y^2+x^2-2-y^2+2=0
Now, let's sum everything up:
2x^2-2y^2=0
Now, we'll leave the 'x' variable (and all of it's components) at the left side of the equation, and we'll pass everything else to the right side of it:
2x^2=2y^2
Now, we'll divide both sides of the equation by two (in order to disable the coefficient of 'x'), and we'll get:
x^2=y^2
Now, in order to get the value of 'x', and not the value of x doubled by x, we'll have to disable the power applied on it, to do this we'll simply multiply both sides of the equation by a square root, so we'll get:
x=y
And there you have it - the value of x equals to the value of y.
I've added a link to a picture where you can see how it's being solved without all the explanations included:
http://planet.nana.co.il/xpilox/solution.JPG
As for the second equation you've asked the solution for:
x-y+sqrt(x^2-2)-sqrt(y^2-3)=0
I'll just solve you the "global" formula you've asked for:
x-y+sqrt(x^2-a)-sqrt(y^2-b)=0
Ok, we'll start off the same way - we'll multiply both of the equation sides by the power of two, in order to disable the square roots:
x^2-y^2+x^2-a-(y^2-b)=0
Now we'll solve the brackets there:
x^2-y^2+x^2-a-y^2+b=0
Let's sum everything up:
2x^2-2y^2-a+b=0
Now we'll isolate the 'x' variable (including all of it's components) from the rest of the variables and parameters by leaving him at the left side of the equation and passing the rest of the stuff to the right side of it:
2x^2=2y^2+a-b
Now we'll divide both of the side equations by two in order to get rid of this coefficient of x, and we'll end up with:
x^2=(2y^2+a-b)/2
Now we've found the value of x when it's doubled by x, and we don't want that - we want the value of x independently, so what we'll do is to multiply each side of the equation by a square root, and so we'll get:
x=sqrt([2y^2+a-b]/2)
I've added a link to a picture where you can see how it's being solved without all of these explanations:
http://planet.nana.co.il/xpilox/sol2.JPG
And there you have it, enjoy :).
If you got any more questions like this (I mean math related), feel free to contact me via ICQ or MSN (I'm using ICQ the most):
ICQ: 242219573
MSN: ariyes@bezeqint.net
I don't check me e-mail often so please make it your last choice.
Yours, Arie.

[Edited by - Phillipe on November 10, 2004 12:01:41 AM]
Mattman
Mattman
Uhhh, isn't it just x = y?
Xai
Xai
actually shouldn't it be:
x = y and x = -y?
Deebo
Deebo
Quote:
Original post by Roboguy
I recommend getting Mathmatica or Maxima instead of asking here everytime you need a formula or equation solved


Or should have stayed awake in 9th grade algebra :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.