Searching \ for '[EE] Math formula help.' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/method/math.htm?key=math
Search entire site for: 'Math formula help.'.

Exact match. Not showing close matches.
'[EE] Math formula help.'
2005\04\01@134218 by

Can anybody help me solve the following equation for 'x' in terms of
a,b,c,d,e,f? I am pretty sure that it is not analytically solvable, but I
would be happy to deal with an iterative solution if it can be simplified
enough.

ax+b        a * sqrt((1-x^2)) +  e
-----   =   ----------------------
cx+d        c * sqrt(1-x^2)) + f

you will note of course this is the same as:

a*sin(theta)+b       a*cos(theta) + e
--------------  =   ----------------
c*sin(theta)+d       c*cos(theta) + f

where x = sin(theta)  (and 'x' is indeed an angle in the range [0..2pi)

TIA,

Bob Ammerman
RAm Systems

On Fri, 1 Apr 2005, Bob Ammerman wrote:
> Can anybody help me solve the following equation for 'x' in terms of
> a,b,c,d,e,f? I am pretty sure that it is not analytically solvable, but I
> would be happy to deal with an iterative solution if it can be simplified
> enough.
>
> ax+b        a * sqrt((1-x^2)) +  e
> -----   =   ----------------------
> cx+d        c * sqrt(1-x^2)) + f

Courtesy Derive(tm),
the greatest little mathematical Crescent wrench(tm) I have.

x = +/- infinity
OR
x = (sqrt(a^2*(d^2 + f^2) - 2*a*c*(b*d + e*f) + b^2*(c^2 - f^2) +
2*b*d*e*f + e^2*(c^2 - d^2))*ABS(a*d - b*c) + (a*f - c*e)*(d*e -
b*f))/(a^2*(d^2 + f^2) - 2*a*c*(b*d + e*f) + c^2*(b^2 + e^2))
OR
x =-(sqrt(a^2*(d^2 + f^2) - 2*a*c*(b*d + e*f) + b^2*(c^2 - f^2) +
2*b*d*e*f + e^2*(c^2 - d^2))*ABS(a*d - b*c) + (a*f - c*e)*(b*f -
d*e))/(a^2*(d^2 + f^2) - 2*a*c*(b*d + e*f) + c^2*(b^2 + e^2)

If you have more specific domain information it might be possible
to further simplify this or put this into a better form for you.

If you find any flaw in this please let me know.
Oops, messed up a couple parentheses, and made couple of other tweaks..
Fixed below.

Bob

> Can anybody help me solve the following equation for 'x' in terms of
> a,b,c,d,e,f? I am pretty sure that it is not analytically solvable, but I
> would be happy to deal with an iterative solution if it can be simplified
> enough.
>
> a*x+b        a * sqrt(1-x^2) +  e
> -----   =   ----------------------
> c*x+d        c * sqrt(1-x^2) + f

Note: x will always be in the range [-1.0..+1.0] (otherwise the sqrt
breaks!)

{Quote hidden}

> --

x is known to be in the range [-1.0..+1.0]
a is positive and finite
b is finite
c is positve and finite
d is finite
e is finite
f is finite

Please also derive with the following fixed values:
a = 0.9375
c = 30

Bob Ammerman

{Original Message removed}

Bob Ammerman wrote:

>> you will note of course this is the same as:
>>
>> a*sin(theta)+b       a*cos(theta) + e
>> --------------  =   ----------------
>> c*sin(theta)+d       c*cos(theta) + f
>>
>> where x = sin(theta)  (and 'theta' is indeed an angle in the range

Bob,

If you cross multiply and collect terms you get:

tan(gamma) * cos(theta) +  sin(theta) + C = 0

Where

C = (de-bf)/(ec-af)

This can be simplified to:

sin(theta + gamma) = -C * cos(gamma)

and solved for theta:

theta = arcsin(-C * cos(gamma)) - gamma

of course,

Scott

It's not an easy one...

I don't know about mathematical crescent wrenches, but my crowbar (ti-89
calculator) spits out this for the sin/cos version:

Still not a clean x, but it might be useful to you as you may be able to
preprocess the coefficients and simplify further.

The equation as written is a monster, but with a better understanding of the
underlying problem, we might be able to help you find a better solution.
-Denny

{Quote hidden}

> --

On Fri, 1 Apr 2005, Bob Ammerman wrote:
>
> x is known to be in the range [-1.0..+1.0]
> a is positive and finite
> b is finite
> c is positve and finite
> d is finite
> e is finite
> f is finite

Those constraints don't seem to provide enough additional information
to provide a smaller solution.  Sorry.

> Please also derive with the following fixed values:
>   a = 0.9375
>   c = 30

(sqrt(256*b^2*(900 - f^2) + 64*b*d*(8*e*f - 225) + d^2*(225 - 256*e^2) +
225*(32*e - f)^2)*ABS(32*b - d) + 16*(32*e - f)*(b*f - d*e))/
(15*((32*b - d)^2 + (32*e - f)^2)

OR

- (sqrt(256*b^2*(900 - f^2) + 64*b*d*(8*e*f - 225) + d^2*(225 - 256*e^2) +
225*(32*e - f)^2)*ABS(32*b - d) + 16*(f - 32*e)*(b*f - d*e))/
(15*((32*b - d)^2 + (32*e - f)^2))

> Thanks for your help Don.

Any time.  If you want to see what it can do,
try a free 30 day full working trial http://www.derive.com.
I don't get paid to say that, I've been a customer
for more than a decade.  (They wrote the code in the TI92/TI89)
Toss me mail if you need help.

> Bob Ammerman
>
> {Original Message removed}

2005\04\01@182526 by
a*sin(theta)+b       a*cos(theta) + e
--------------  =   ----------------
c*sin(theta)+d       c*cos(theta) + f

solved for theta by Scott Datallo's magic gives:

theta = arcsin(-C * cos(gamma)) - gamma

where C = (de-bf)/(ec-af)
and    gamma = arctan( (ad-bc)/(ec-af) )

Scott, you nailed it!

It took me a bit to figure out a couple of your steps, but then I remembered
my sum-of-angles formulae and off I went.

Did you do this by hand or use some tool? What prompted the brilliant
substitution of tan(gamma) = (ad-bc)/(ec-af) ??

I am in awe!

Bob Ammerman
RAm Systems

{Original Message removed}

----- Original Message -----
From: "Denny Esterline" <firmwaretds.net>
To: "Microcontroller discussion list - Public." <piclistmit.edu>
Sent: Friday, April 01, 2005 5:07 PM
Subject: Re: [EE] Math formula help.

> It's not an easy one...
>
> I don't know about mathematical crescent wrenches, but my crowbar (ti-89
> calculator) spits out this for the sin/cos version:
>

Your calculator got partway there. Unfortunately it doesn't appear to be as
bright as Scott Dattalo!

> The equation as written is a monster, but with a better understanding of
> the
> underlying problem, we might be able to help you find a better solution.

The underlying problem was trying to determine the correct angle to fire a
gun of a certain length (gunLength) so that the projectile, travelling at a
given velocity (bulletSpeed) would intercept an object that starts at
location (x0,y0) relative to the gun and moves at velocity (deltaX,deltaY).

Here is where the formula came from:

where will the bullet be at time t relative to shoot time?

sin(theta)*(gunLength + bulletSpeed*t)
cos(theta)*(gunLength + bulletSpeed*t)

where will the enemy be at time t relative to shoot time?

x0+deltaX*t
y0+deltaY*t

so, the bullet hits the enemy when the two are at the same point:

sin(theta)*(gunLength + bulletSpeed*t) = x0+deltaX*t
cos(theta)*(gunLength + bulletSpeed*t) = y0+deltaY*t

then solve each of the two equations above for t:

(sin(theta)*gunLength-x0)
t  =  -------------------------------
(deltaX-sin(theta)*bulletSpeed)

and:

(cos(theta)*gunLength-y0)
t = --------------------------------
(deltaY-cos(theta)*bulletSpeed)

Now use the above two substitutions for t to create an equation that has
theta as the only unknown:

cos(theta)*gunLength - y0                 sin(theta)*gunLength-x0
-------------------------------     =    -------------------------------
deltaY-cos(theta)*bulletSpeed           deltaX - sin(theta)*bulletSpeed

Doing a little judicious juggling and sign changing I substituted single
letters for the funny variable names to create my post:

a = gunLength
c = -bulletSpeed
b = -x0
d = deltaX
e = -y0
f  = deltaY

Oh, and don't ask what I needed to know this for.. :-)

Bob Ammerman
RAm Systems

Bob Ammerman wrote:
> a*sin(theta)+b       a*cos(theta) + e
> --------------  =   ----------------
> c*sin(theta)+d       c*cos(theta) + f
>
> solved for theta by Scott Datallo's magic gives:
>
> theta = arcsin(-C * cos(gamma)) - gamma
>
> where C = (de-bf)/(ec-af)
> and    gamma = arctan( (ad-bc)/(ec-af) )
>
>
> Scott, you nailed it!
>
> It took me a bit to figure out a couple of your steps, but then I
> remembered my sum-of-angles formulae and off I went.
>
> Did you do this by hand or use some tool? What prompted the brilliant
> substitution of tan(gamma) = (ad-bc)/(ec-af) ??

Hi Bob,

It wasn't too hard to solve. When you cross multiply, you get:

ac*sin(theta)cos(theta) + bc*cos(theta) + af*sin(theta) + bf =
ac*sin(theta)cos(theta) + ad*cos(theta) + ec*sin(theta) + de

Then collect terms and cancel:

(ad-bc)cos(theta) + (ec-af)sin(theta) + (de-bf) = 0

Now, the trick is that you want to use the Trig identity:

sin(X+Y) = sin(X)cos(Y) + sin(Y)cos(X)

Substitute this into the above equation.

sin(gamma)cos(theta) + cos(gamma)sin(theta) + (de-bf) = 0

then apply the identity:

sin(gamma + theta) + de-bf = 0

and solve:

theta = arcsin(-de+bf) - gamma

I originally wrote that the argument of the arcsin was:

-(de-bf)/(ec-af) * cos(gamma)

However, you can see that since the cos(gamma) is (ec-af), that this
expression can be simplified.

Finally, you can find gamma from either:

ec-af = cos(gamma)

or by taking the ratio and using tan().

Scott

PS, I hope this is for Paint Ball!
> Scott, you nailed it!
>
> It took me a bit to figure out a couple of your steps, but
> then I remembered my sum-of-angles formulae and off I went.
>
> Did you do this by hand or use some tool? What prompted the
> brilliant substitution of tan(gamma) = (ad-bc)/(ec-af) ??
>
> I am in awe!
>
> Bob Ammerman
> RAm Systems
>

See! Now isn't it worth policing the tags a bit to keep Scott and others
like him on the list?

If Scott gets swamped with non-PIC related tags under the [PIC] tag which is
all he has time to subscribe to, then he is going to leave...

...wait a minute...

This was tagged [EE]... Scott? What are you doing messing up my argument by
subscribing to [EE] tags? You don't have time for this!

<GRIN>

Anyway...

Watch the tags.

---
jamesnewtonpiclist.com  1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com

> Hi Bob,
>
> It wasn't too hard to solve. When you cross multiply, you get:
>
>
> ac*sin(theta)cos(theta) + bc*cos(theta) + af*sin(theta) + bf =
> ac*sin(theta)cos(theta) + ad*cos(theta) + ec*sin(theta) + de

No problem here.

> Then collect terms and cancel:
>
> (ad-bc)cos(theta) + (ec-af)sin(theta) + (de-bf) = 0

Again, this makes sense.

> Now, the trick is that you want to use the Trig identity:
>
> sin(X+Y) = sin(X)cos(Y) + sin(Y)cos(X)

Ah, now I see where you were going here. You saw an eq in the form:

A sin(x) + B cos(x) + junk = 0

and realized that if you treated A as cos(gamma)
and B as sin(gamma) for some angle that you'd be able to use
the sum of angles formula. So, then A/B becomes tan(gamma)
and the rest of it just happens!

But.... doesn't this constrain:

(ad-bc) to be in the range [-1..+1]

and:

(ec-af) to also be in the range [-1..+1]

??

My original problem doesn't have those constraints. Will this magic still
work????

{Quote hidden}

Yeah, nice catch....

so in the end we get:

theta = arcsin( bf-de ) - arcsin( ad-bc )

Which at least has some sort of symmetry to it.

> Finally, you can find gamma from either:
>
> ec-af = cos(gamma)
>
> or by taking the ratio and using tan().
>
> Scott
>
> PS, I hope this is for Paint Ball!
> --

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...