# x(b) ... a(x,b) ... to give a(x) Mike Eghtebas used Ask the Experts™
on
I have following two equations (r and h are constants):

x=x(b)=r (cos(b)+ tan(b)sin(b)-1)+ tan(b)h                   (eq. 1)

a =a(x,b)= (1/r)*sqrt((h + rsin(b))^2 + (x + r - rcos(b))^2) - b-h/r               (eg. 2)

to make it readable, if we assume S=Sin(b), C=Cos(b), and T=tan(b), then we get:

x=x(b)=r (C+ TS -1)+ Th      <-- these forms may be useful may be not
a =a(x,b)= (1/r)*sqrt((h + rS)^2 + (x + r - rC)^2) - b-h/r;

I want to have the following functions if possible:

a(x)=....?            (eq. 3)
b(x)=....?           (eq. 4)   <-- this one is not that important.

Question:  Is it possible to find a(x) and b(x) having (eq. 1) and (eq. 4) above?

for background discussions please see: http://www.experts-exchange.com/Programming/Languages/Scripting/Q_27237703.html

Thank you
Comment
Watch Question

Do more with EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Awarded 2010
Top Expert 2013

Commented:
What is b(x)? I don't see b shown as a function anywhere.
Also, if a is defined as taking two parameters then how do you drop one? How do you get from a(x,b) to just a(x)? The only way I could think of where that would make sense would be if b cancelled out of the equation, but it's not going to.

Database and Application Developer

Commented:
re:> What is b(x)? I don't see b shown as a function anywhere

lets ignore b(x).  But, if we had it in a much simpler form say x=rcos(b) then

b=ArcCos(x/r)    and now we have b(x)=ArcCos(x/r)

re:> Also, if a is defined as taking two parameters then how do you drop one? How do you get from a(x,b) ...

This is why I am posting the question here hoping someone familiar with chain function possibly could come up with the answer.

thx
Analyst Programmer
Commented:
Trying to solve:

By eq. 1, you may get

x = r (C+ TS -1)+ Th
=>  x = (r-rC)/C + Sh/C
=>  Cx - (r-rC) = Sh
=>  C (x +r) -r = Sh ...... (eq. 5)
=>  C^2(x+r)^2 + r^2 - 2 r(x+r) C = (1-C^2)h^2
=>  C^2[(x+r)^2+h^2] - 2r(x+r) C + r^2-h^2 = 0 ..... (eq. 6)

By solving eq.6,
C = [2r(x+r) + sqrt(4r^2(x+r)^2-4[(x+r)^2+h^2](r^2-h^2)])]/2[(x+r)^2+h^2]
=> C = [r(x+r) +  h sqrt(-r^2+(x+r)^2+h^2)] / [(x+r)^2+h^2]
=> b = ArcCos([r(x+r) +  h sqrt(-r^2+(x+r)^2+h^2)] / [(x+r)^2+h^2]) ................... (eq. 7)

or

C = [2r(x+r) - sqrt(4r^2(x+r)^2-4[(x+r)^2+h^2](r^2-h^2)])]/2[(x+r)^2+h^2]
=> C = [r(x+r) -  h sqrt(-r^2+(x+r)^2+h^2)] / [(x+r)^2+h^2]
=> b = ArcCos([r(x+r) -  h sqrt(-r^2+(x+r)^2+h^2)] / [(x+r)^2+h^2]) ................... (eq. 8)

a = (1/r)*sqrt((h + rS)^2 + (x + r - rC)^2) - b-h/r
= (1/r)*sqrt(h^2+2rSh + r^2S^2 + (x+r)^2 - 2r(x+r)C + r^2C^2) - b - h/r
= (1/r)*sqrt(h^2 +(x+r)^2+2r(C(x+r)-r) -2r(x+r)C+r^2)-b-h/r         // By substituting (eq. 5) into Sh
= (1/r)*sqrt((x+r)^2+h^2-r^2) - b-h/r ........................... (eq. 9)

By substituting eq. 7 into eq. 9

a = (1/r)*sqrt((x+r)^2+h^2-r^2) -h/r - ArcCos([r(x+r) +  h sqrt(-r^2+(x+r)^2+h^2)] / [(x+r)^2+h^2]) ... (eq. 10)

or
a = (1/r)*sqrt((x+r)^2+h^2-r^2) -h/r - ArcCos([r(x+r) -  h sqrt(-r^2+(x+r)^2+h^2)] / [(x+r)^2+h^2]) ... (eq. 11)

Awarded 2010
Top Expert 2013

Commented:
Okay I get it. So b(x) actually is important because you replace b in the a(x,b) equation with b(x). I've never seen equations expressed as functions, but it makes sense.

I verified pkwan's math and it looks good. He used the trig identities S^2 + C^2 = 1 and S/C = T to derive eq 6 and the quadratic formula to derive eqs 7 and 8. The rest is just pretty simple algebra. Very well done.

Don't forget that when you introduce an ArcCos, you need to constrain the domain.

Commented:
When x = 0, a should be 0...
====

>> x = 10 (cos(b)+ tan(b)sin(b)-1)+ tan(b)60
When b = 0, then x is 0 and vice-versa
http://www.wolframalpha.com/input/?i=10+%28cos%28b%29%2B+tan%28b%29sin%28b%29-1%29%2B+tan%28b%2960+for+b%3D0+to+pi%2F2

====

>> a(0,b) = (1/10)*sqrt((60 + 10sin(b))^2 + (0 + 10 - 10cos(b))^2) - b-60/10
When b and x are 0, a is 0
http://www.wolframalpha.com/input/?i=%281%2F10%29*sqrt%28%2860+%2B+10sin%280%29%29%5E2+%2B+%280+%2B+10+-+10cos%280%29%29%5E2%29+-+0-60%2F10

====
But, ...
>> a = (1/r)*sqrt((x+r)^2+h^2-r^2) -h/r - ArcCos([r(x+r) -  h sqrt(-r^2+(x+r)^2+h^2)] / [(x+r)^2+h^2]) ... (eq. 11)

So, for equivalency, if x = 0, then a should be 0, but..

http://www.wolframalpha.com/input/?i=%281%2F10%29*sqrt%28%28x%2B10%29%5E2%2B60%5E2-10%5E2%29+-60%2F10+-+ArcCos%28%5B10%28x%2B10%29+-++60+sqrt%28-10%5E2%2B%28x%2B10%29%5E2%2B60%5E2%29%5D+%2F+%5B%28x%2B10%29%5E2%2B60%5E2%5D%29%2C+for+x+%3D+0+to+45

====

On another note, not related to this question, when looking at the graphs, it appears that the relationship between a and b is suspect, since for large x, then a small change in b should result in a large change in a. See related question: http://rdsrc.us/qNFw9P
Database and Application Developer

Commented:
Hi pkwan,

Thank you for the solution. I included the functions in a java program shown below to test the equations.

At x=0, I was expecting to get zero for both a and b, but I am getting:

angle a       angel b    x
-02.81  02.81  00.00
-02.79  02.80  00.25
-02.78  02.80  00.50

-00.01  02.26  23.75
00.03  02.25  24.00
00.07  02.25  24.25
00.11  02.25  24.50
00.15  02.24  24.75
00.19  02.24  25.00

06.26  01.94  59.50
06.30  01.93  59.75

Most likely this dicrepency is due to my mistkes converting from your math equation to java equations shown below:

I will go over it to locate my mistakes.
``````import java.text.DecimalFormat;
public class Data1 {
public static void main(String args[]) {
DecimalFormat df = new DecimalFormat("00.00");
double h = 30;
double r = 5;
double a = 0;
double b = 0;
System.out.println("angle a\t angel b    x");
for(double x = 0; x < 60; x +=0.25){

//b = ArcCos([r(x+r) +  h sqrt(-r^2+(x+r)^2+h^2)] / [(x+r)^2+h^2]) ................... (eq. 7)
b = Math.acos((r*(x+r) -  h*Math.sqrt(-Math.pow(r,2)+Math.pow((x+r),2)+
Math.pow(h,2))) / (Math.pow((x+r),2)+Math.pow(h,2)));

// a = (1/r)*sqrt((x+r)^2+h^2-r^2) -h/r - ArcCos([r(x+r) -  h sqrt(-r^2+(x+r)^2+h^2)] / [(x+r)^2+h^2]) ... (eq. 11)
a=(1/r)*Math.sqrt(Math.pow((x+r),2)+Math.pow(h,2)-Math.pow(r,2))-(h/r)-
Math.acos((r*(x+r)-h*Math.sqrt(-1*Math.pow(r,2)+Math.pow((x+r),2)+
Math.pow(h,2)))/((Math.pow((x+r),2)+Math.pow(h,2))));

//          System.out.println(" " + df.format(a*(180/Math.PI)) + "  " + df.format(b*(180/Math.PI)) + "  " + df.format(x));
System.out.println(" " + df.format(a) + "  " + df.format(b) + "  " + df.format(x));
}
}
}
``````
Database and Application Developer

Commented:
Hi phoffric,

Database and Application Developer

Commented:
I should have used:

x=x(b)=r (cos(b)+ tan(b)sin(b)-1)+ tan(b)h                   (eq. 1)

a = (r *tan(b) + h/cos(b) - h)/r - b                                 (eg. 2) much simpler

x = r (C+T S -1)+T/h                                                       (eq. 1a)
a = (r T + h/C - h)/r - b                                                   (eg. 2a)

now will try the solution from pkwan on these two equations,

brb
Database and Application Developer

Commented:
pkwan,

I wonder if you have some time to take a look at this:

http://www.experts-exchange.com/Other/Math_Science/Q_27242530.html

Thank you,

Mike

Do more with 