LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I solve Two Simultaneous Equations?

Hi All,

I have the following equation (X and Y are variables and A and B are constants)

Y=B*Cos(X-A)

and i have two values of Y (0.683,1.199) and two values of X (-10.232,-10.505 in Radians), thus two equations:

0.683=B*Cos(-10.232-A)
1.199=B*Cos(-10.505-A)

How do i get A and B?

Thanks for your help,
0 Kudos
Message 1 of 11
(4,868 Views)
I think a direct algebraic solution is not possible. Thus an iterative numeric solution seems like the best approach. Select an initial guess for one of the parameters, perhaps Bo. Using the Inverse Cosine function, obtain two values for Ao:

Ao1 = x1 - arccos(y1/Bo)

A02 = x2 - arccos(y2/Bo)

Use those vaues to obtain the improved estimate of B, B1. (I am not sure what to recommend here. One of the numerical calculation gurus may be able to help.) Repeat until An and Bn are close enough.

Lynn
0 Kudos
Message 2 of 11
(4,868 Views)
Starting with

Y0 = B*cos(X0 - A) and
Y1 = B*cos(X1 - A)

you can get a closed form solution:

B = Y0/cos(X0 - A) = Y1/cos(X1 - A)  (1)

then

Y1*cos(X0 - A) = Y0*cos(X1 - A)

expanding the cosine difference, (please double check...) and dividing by cos(A) you'll get

tan(A) = (Y1*cos(X0) - Y0*cos(X1))/(Y1*sin(X0) - Y0*cos(X1))

Compute A and replace in (1)

LEK




LabVIEW, C'est LabVIEW

0 Kudos
Message 3 of 11
(4,851 Views)
There is a vi in the math sub-palette (with the zeroes functions), named "Nonlinear System Solver" that seems to be the right tool for this sort of job...
Chilly Charly    (aka CC)
0 Kudos
Message 4 of 11
(4,756 Views)
Jean-Pierre,

Thank you. I suspected that a closed form solution might be possible, but I did not spend very much time seeking it out.

I get a sign difference when I derive the result. Cos(a-b) = cos(a)*cos(b) + sin (a)*sin(b).

Then tan(A) = (Y1*cos(X0) - Y0*cos(X1))/(-Y1*sin(X0) + Y0*cos(X1))

Lynn
Message 5 of 11
(4,833 Views)


johnsold a écrit:
Jean-Pierre,

Thank you. I suspected that a closed form solution might be possible, but I did not spend very much time seeking it out.

I get a sign difference when I derive the result. Cos(a-b) = cos(a)*cos(b) + sin (a)*sin(b).

Then tan(A) = (Y1*cos(X0) - Y0*cos(X1))/(-Y1*sin(X0) + Y0*cos(X1))

Lynn



Yeah exactly the formula in my math table that I looked twice into before deriving.... Smiley Surprised
And an other error it should be:

tan(A) = (Y1*cos(X0) - Y0*cos(X1))/(-Y1*sin(X0) + Y0*sin(X1))

CC: numerical solutions are for the lazy... Smiley Happy




LabVIEW, C'est LabVIEW

0 Kudos
Message 6 of 11
(4,826 Views)
JPD,
I am lazy...
Chilly Charly    (aka CC)
0 Kudos
Message 7 of 11
(4,815 Views)

OK, I'll join in.  here is what I get:

Start with Y1*cos(X0-A) = Y0*cos(X1-A) and the well known derivation cos(a-b) = cos(a)*cos(b) + sin(a)*sin(b)

then upon expanding:  Y1*[cos(X0)*cos(A) + sin(X0)*sin(A)] = Y0*[cos(X1)*cos(A) + sin(X1)*sin(A)]

then getting rid of [ ]:  Y1*cos(X0)*cos(A) + Y1*sin(X0)*sin(A) = Y0*cos(X1)*cos(A) + Y0*sin(X1)*sin(A)

then divide by cos(A):  Y1*cos(X0) + Y1*sin(X0)*tan(A) = Y0*cos(X1) + Y0*sin(X1)*tan(A)

rearrange terms:  Y1*sin(X0)*tan(A) - Y0*sin(X1)*tan(A) = Y0*cos(X1) - Y1*cos(X0)

tan(A) is common:  tan(A)*[Y1*sin(X0) - Y0*sin(X1)] = Y0*cos(X1) - Y1*cos(X0)

solve for tan(A):  tan(A) = [Y0*cos(X1) - Y1*cos(X0)] / [Y1*sin(X0) - Y0*sin(X1)]

So, Mr. Lynn is wrong, and Monseiur Jean Pierre is still wrong, unless I made a mistake and then I'm wrong!!!Smiley Tongue
- tbob

Inventor of the WORM Global
Message 8 of 11
(4,810 Views)
That is the same answer and we are both right (unless proven otherwise) the apparent difference is that the signs of both numerator and divider are reversed (mutiplied by( -1)/(-1))


LabVIEW, C'est LabVIEW

0 Kudos
Message 9 of 11
(4,806 Views)
Jean-Pierre and tbob,

I tried to copy and paste and modify and did not check carefully enough. Your final answers are both correct and the same within (-1)/(-1), which is close enough except for those doing numerical simulations where 1 +/- 2E-15 might be better.

I guess tbob does not need to address me as Mr. Lynn any longer.

Lynn
0 Kudos
Message 10 of 11
(4,797 Views)