pus pure u etapps/assess enttakertake sp?course assessment i1-195001&co; urse m
ID: 2266378 • Letter: P
Question
pus pure u etapps/assess enttakertake sp?course assessment i1-195001&co; urse m id 11493 1&content;_id,4306751question num 4 x 0&toggle; statesqShowE Description Respondus Multiple Altempts This test allows multiple attempts Force Completion This test can be saved and resunmed laler This test does not allow backtracking. Changes to the answer after submission are prohibited e Question Completion Status Save and Submit Question 5 of 5 Click Submit to complete this assessment. 1 points Save Answer Question 5 7using the Secant method with an initial x the minimun number of iterations needed to reach a tolerance of 5x1010 when finding a zero in the function f(x) bracket ot[ 1.62, 1.63] Question 5 of 5 Click Submit to complote this assessment S28 AM !Explanation / Answer
The minimum number of iterations occurs when we take 1.63 as initial guess i.e 4
If we take 1.62 as initial guess 5 iterations are required to converge.
So minimum iterations are 4 with initial guess 1.63.
Code:
/* secant point Method */
/* fun 1:(667.38/x)*(1-exp(-0.146843*x))-40*/
/* fun 2:pow(x,10)-1*/
/* fun 3:exp(-0.005*x)*cos(sqrt(2000-0.01*x*x)*0.05)-0.01 */
/*fun 4: exp(-x)-x; */
/*fun 5: log(x) */
#include<stdio.h>
#include<math.h>
/*#include<stdlib.h> */
float dfun (float x)
{
return (10*pow(x,9));
}
float fun (float x)
{
return (pow(x,4)-7);
}
int main ()
{
float xo,es,xr,ea,xrold1,xrold2=1;
int iter,imax;
printf(" Enter intial point:");
scanf("%f", &xo);
printf(" Enter the value stop percentage of error:");
scanf("%f", &es);
printf(" Enter the max no.of iterations:");
scanf("%d", &imax);
printf(" itr.no xr ea ");
xr=xo;
iter=0;
do
{
xrold1=xr;
xr=xrold1-(fun(xrold1)*(xrold2-xrold1))/(fun(xrold2)-fun(xrold1));
iter=iter+1;
if(xr != 0)
ea=fabs((xr-xrold1)/xr)*100;
printf(" %d %f %f",iter,xr,ea);
xrold2=xrold1;
}while(ea > es && iter <= imax);
printf(" The root of the equation after %d itterations is = %f",iter,xr);
printf(" value of the function at above xr is = %f",fun(xr));
return 1;
}
Output:
Enter initial point:1.63
Enter the value stop percentage of error:.0000000005
Enter the max no.of iterations:20
itr.no xr ea
1 1.623853 0.378531
2 1.626568 0.166901
3 1.626577 0.000528
4 1.626577 0.000000
Number of iterations = 4
The root of the equation after 4 itterations is = 1.626577
value of the function at above xr is = -0.000000
--------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.