Jump to content

Recommended Posts

Posted (edited)

I am stuck at solving for the y-intercept of y= x+cosx. Can anyone show me how to solve for the y intercept?

 

I figured out that cosx=-x for x+cosx=0, but I don't know how to compute the value of x such that cosx=-x.

Edited by Vay
Posted
I don't know how to compute the value of x such that cosx=-x.

I do something probably horrible in the eyes of true mathematicians. I use Excel, put a beginning value in one cell, and put the negative cosine of that cell in another cell, and I put their average of the two in a third cell.

 

For a beginning value, zero is a good place to start because it's the mid-range of the cosine, which runs between +1 and –1. In five iterations, you should get three place accuracy.

Posted

I don't know of any way to solve that analytically.

Ewmon's method is as practical as any other numerical method in this case.

You can formalize it somewhat, or use other formal methods if that is important -- they usually require calculus though.

Posted (edited)

I guess I exaggerated a bit about mathematicians cringing about the method. It is acceptable as Schrödinger's hat points out, and here's a graphical example of a similar method where two functions have the same value. You can see the method starting at zero and converging on the intersection where both functions have the same value. In your case, Vay, the functions are y=cos(x) and y=–x.

 

Schrödinger's hat, would you be able to give these methods a name. I have forgotten it myself.

 

id3.gif

Edited by ewmon
Posted (edited)

why don't you just use x= 0 ?

 

the y intercept is where it crosses the y-axis (x=0) not when y equals zero, that's the x-intercept

 

 

That's what I was thinking. It seems like a really easy problem. That makes it y(0)=cos(0). And everyone should know the value of cos0.

Edited by ydoaPs
Posted (edited)

I was hoping for the general solution, but my teacher says I just have to calculate this on a scientific calculator for now. My textbook is really bad. It gives you easy examples, which the author solves, then for the homework exercises, there are all sorts of difficult questions that were never shown how to solve by the author.

Edited by Vay
Posted

There are two issues here, Vay. You asked for the "y-intercept of y= x+cosx", but then you asked for how to solve x+cos(x)=0. Issue #1 is that this is not the y intercept. That's the x intercept, not the y intercept. The y intercept is trivial: just solve for y with x=0. Issue #2 is the solution to x+cos(x)=0. This is a transcendental equation. There is no solution in the elementary functions.

 

There are a number of ways to solve this numerically. One simple technique is to use a fixed point iteration scheme. Start with some initial guess, say x1=0. Now use this for your next guess via x=-cos(x). This yields x2=-cos(x1)=-cos(0)=-1. The next step yields x3=-cos(x2)=-cos(-1)=-0.54. After several of these iterations you will find that the sequence converges on a particular value.

 

Fixed point iteration doesn't always work, but it does work in this case. It's not very fast, either, but it is simple.

 

Ewmon's scheme is quite a bit faster in this case, but his scheme also fails in some cases, and it can be agonizingly slow in others. Try solving x=1.002*sin(x) using Ewmon's scheme, for example. His scheme is slow, slow, slow for this problem -- even if you start with a good guess such as 0.1.

Posted

Slow? Just throw more computing power at it -- it's what everyone else does. :D

javascript:(function(){var x = 1,xo = 0;while(x - xo){xo = x;x = 1.002 * Math.sin(x)};alert('Solution: ' + x)})();

(I was going to make it a hyperlink, but xss protections ruined my fun :( -- should work if you paste into URL bar unless your browser has similar anti-social-engineering protections)

 

Also, another interesting note that this example brings up, is methods like these require a good guess for finding all of the solutions. A human is much more capable of finding the x=0 solution here than a computer using this method.

Posted (edited)

Slow? Just throw more computing power at it -- it's what everyone else does. :D

javascript:(function(){var x = 1,xo = 0;while(x - xo){xo = x;x = 1.002 * Math.sin(x)};alert('Solution: ' + x)})();

Try using that technique to find a non-zero root of [math]x_{n+1}=\tan(x_n)[/math]. It won't work, period. It is unstable. It doesn't even work for finding the trivial solution.

 

"Throwing more computer power at it" is not what everyone else does. At least not in the world of numerical computation. It is nice to have ever more computing power to throw at a problem because this makes formerly intractable problems become tractable. Use bad techniques and even formerly tractable problems suddenly become intractable.

Edited by D H
Posted (edited)

Try using that technique to find a non-zero root of [math]x_{n+1}=\tan(x_n)[/math]. It won't work, period. It is unstable. It doesn't even work for finding the trivial solution.

 

"Throwing more computer power at it" is not what everyone else does. At least not in the world of numerical computation. It is nice to have ever more computing power to throw at a problem because this makes formerly intractable problems become tractable. Use bad techniques and even formerly tractable problems suddenly become intractable.

 

I was attempting to be facetious for humor value. I realise choice of method and design of algorithm is far more important than the amount of computing power available. Apologies if I gave offense. I thought my note at the end made it clear that I didn't actually think that was a good technique.

Edited by Schrödinger's hat

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.