Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numerical Solution of Trigonometric Equation 2

Status
Not open for further replies.

GrimesFrank

Mechanical
Sep 11, 2006
149
0
0
CA
I have a formula;
y = A[÷]cos(x) + B*sin(x)

Is there a download (VB savant I am not) that will solve for x when varying y? A & B are constants.

Thank-you for your help.
 
Replies continue below

Recommended for you

if you only need to solve a few points, the excel "solver" or "goal seek" tools will do a great job at this.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
For a case like this I'd manipulate the terms to express it in terms of y and cos(x) only, then solve for cos(x), and hence x.

corus
 
Solving for cos(x) yields a huge equation. I substituted C=cos(x), with sin(x)=sqrt(1-C²), in the original equation and solved for C in MathCAD and got a result 141 pages long.
 
The substitution C=cos(x), with sin(x)=sqrt(1-C²) does reduce the original equation to the quartic equation in C:

B^2*C^4+(y^2-B^2)*C^2-2*C*y*A+A^2 = 0

But that equation does not have any simple analytical solution. Maple didn't quite take 141 pages, but it is an ugly result that is waaaay to cumbersome to work with (unless you want to leave it in Maple or whatever symbolic program you're using).

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
(sound of hasty scrabbling in dusty tomes)

Isn't the solution space of x effectively limited to 0 to 2*pi?


Y*cos(x)-A-B*sin(x)*cos(x)=0

Doesn't look hard does it?











Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Reverse superposition?

y1 = A/Cos(x) ; x = acos(A/y1)

y2 = B*sin(x) ; x = asin(y2/B)

y = y1 + y2

Three equations, three unknowns. Should be solvable (although I can't do it).
 
Here's a disgusting Excel based method.

Y*cos(x)-A-B*sin(x)*cos(x)

set up a column of x 0, 0.01 ...6.29

set up the above equation in the second column

x is a solution when that is zero.

square the second column, find its minimum (MIN)

Look up the corresponding x value with VLOOKUP

call this x0


set up a refined range for x about x0, using steps of 0.0001

shampoo, rinse and repeat to any arbitrary limit of accuracy.

I warned you it was nasty.

Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Simplifying the expression to constants multiplied by powers of cos(x) gives a matrix solution in Mathcad of about 4 pages for me.

By inspection, a solution for the case y=A is cos(x)=1.

If this is maths homework then to get top marks just say that the solution is trivial. They'll think you're a genius, believe me.

corus
 
Greg - you did verify that result by hand, right?

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
As I posted earlier, I think the proper method to use is Newton-Raphson. The math is a very straight forward iterative scheme and is commonly used for finding numerical solutions to nonlinear equations or system of equations. I wouldn't bother trying to find an explicit form for x.

I2I
 
I agree on the suggestion of numerical method as I think we have proved in gory detail the analytical solution is a PITA.

Newton-Rhapson is one numerical method. There is also excel's solver, and Maple's fsolve, and I'm sure there are plenty more out there.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Status
Not open for further replies.
Back
Top