: Given the equation ?(?) = −2?^6 − 1.6?^4 + 12? + 1
Write a code to use the bisection method to calculate the maximum between [0,1]. Iterate until the approximate absolute error falls below 5%. Print the root and number of iterations on the screen.
I've done this so far with the script but I don't know where to go from here. Please help.
syms xf(x)=-2*x^6-1.6*x^4+12*x+1;dfdx= diff(f,x);a=0;b=1;i=0;err=1000;while err>0.05 c=(a+b)/2 if double((dfdx(a)))*double((dfdx(c)))<0 a=c else b=c end err=; i=i+1;endfprintf('The max of equation in [0,1] is %f by %d',c, i)
Best Answer