interpolation for 4cos(x) − ex = 0

1 回表示 (過去 30 日間)
xbhax
xbhax 2021 年 11 月 22 日
コメント済み: xbhax 2021 年 11 月 22 日
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 件のコメント
James Tursa
James Tursa 2021 年 11 月 22 日
編集済み: James Tursa 2021 年 11 月 22 日
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?
xbhax
xbhax 2021 年 11 月 22 日
no, i cant use polyfit nor roots for this... and yes to the 1st question :)

サインインしてコメントする。

採用された回答

James Tursa
James Tursa 2021 年 11 月 22 日
編集済み: James Tursa 2021 年 11 月 22 日
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 件のコメント
James Tursa
James Tursa 2021 年 11 月 22 日
編集済み: James Tursa 2021 年 11 月 22 日
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.
xbhax
xbhax 2021 年 11 月 22 日
got it! thanks a lot! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by