Matlab Help plz! f1 (x) = -69.3 - 3.84 x + 60.64 x^2 - 10.92 x^3 - 5.1 x^4 + x^5
ID: 3666799 • Letter: M
Question
Matlab Help plz!
f1 (x) = -69.3 - 3.84 x + 60.64 x^2 - 10.92 x^3 - 5.1 x^4 + x^5 f2(x) = x - cos(2 x / pi). Create inline functions for each of f1, f2. Plot the functions over the interval [0, 4]. This will enable you to get good starting guesses to find the roots. Find the first positive root of each function using A bisection routine of your own. A false position routine of your own. The matlab function fzero(). For the first two of these (bisection, false position), compare how many iterations it takes to find the root to a stopping criterion of 1e-6, using the same starting guesses for each function. Comment on this. That your two codes should take the inline functions as arguments That the beginning of the bisection routine I wrote in class can be your starting point, but be aware that it needs work (it won't work as written).Explanation / Answer
#include <iostream.h>
#include <math.h>
using namespace std;
inline void fun1()
{
for(int x=0;x<=4;x++)
{
cout<<-69.3-3.84 +(60.64*pow(x,3))-(10.90*pow(x,3))-(5.1*pow(x,4))+pow(x,5) << endl;
}
}
inline void fun2()
{
for(int x=0;x<=4;x++)
{
;
}
}
int main()
{
fun1();//Call it like a normal function...
fun2();
}