interpolation for 4cos(x) − ex = 0
3 views (last 30 days)
Show older comments
theres only one positive root for the equation 4cos(x) − ex = 0 for [0,1] domain. use a parabolic function calculated through interpolation to find the approximation for this root. you can choose whatever points you want.
any idea on how to solve this? thanks yall in advance!
4 Comments
James Tursa
on 22 Nov 2021
Edited: James Tursa
on 22 Nov 2021
Are you supposed to pick any three points you want, fit a parabola to those points, and then find the root of that parabola in the [0,1] domain? Can you use the MATLAB polyfit( ) and roots( ) functions for this? Or are you supposed to be using hand-written code?
Accepted Answer
James Tursa
on 22 Nov 2021
Edited: James Tursa
on 22 Nov 2021
Without seeing the text of your assignment, I would presume that this is the outline of what you are supposed to do:
1) Define the function y(x) = 4*cos(x) − exp(x)
2) Pick three points of this function near the desired root in interval [0,1], e.g. (0,f(0)), (0.5, f(0.5)), (1,f(1))
3) Fit a parabola to those three points
4) Find the root of that parabola in the [0,1] interval
Steps 1 and 2 are very easy. Step 3 would have been very easy with polyfit( ), but it is still easy to solve for arbitrary parabola coefficients using a hand written algorithm. Just ask yourself if you have three points (x1,y1,), (x2,y2), and (x3,y3), how would you write the equation of a parabola that passed through these three points? That would give you three equations in three unknowns (the parabola coefficients a, b, c). Then step 4 is easy with your own quadratic formula or other quadratic root code.
See if you can figure out step 3 and come back with any problems you might have.
4 Comments
James Tursa
on 22 Nov 2021
Edited: James Tursa
on 22 Nov 2021
I was using a, b, and c to denote the coefficients of the quadratic function. This doesn't match what you have for a, b, and c above.
To solve for the roots of a quadratic function, you could simply use the quadratic formula. That will give you the x value approximation of the root to the original function.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!