# include # include /*****************************************************************/ void rtfunct(float x) /* Given function f(x) = 0 */ { extern float fx, dfx; switch(problem_id) { case 1: /* Problem-1 */ fx = 1+5.25*x-1/cos(sqrt(0.68*x)); dfx = 5.25-(0.4123/sqrt(x))*sin(sqrt(0.68*x))/(cos(sqrt(0.68*x))*cos(sqrt(0.68*x))); break; case 2: /* Problem-2 */ fx = 1+x*x-8*x+16; dfx = 2*x-8; break; case 3: /* Problem-3 */ fx = x*x-8*x+16; dfx = 2*x-8; break; case 4: /* Problem-4 */ fx = x*x*x-5*x+1; dfx = 3*x*x-5; break; case 5: /* Problem-5 */ fx = cos(x)-x*exp(x); dfx = -sin(x)-exp(x)-x*exp(x); break; case 6: /* Problem-6 */ fx = sin(x); dfx = cos(x); break; case 7: /* Problem-7 */ fx = 1+sin(x); dfx = cos(x); break; case 8: /* Problem-8 */ fx = tan(x); dfx = 1/(cos(x)*cos(x)); break; } return; } /*****************************************************************/