Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

we learned about loop (for, do while), if, pointer, and we usually use printf, s

ID: 3677019 • Letter: W

Question

we learned about loop (for, do while), if, pointer, and we usually use printf, scanf for printing out value

Also, could you guys use function which is on the above paper sheet?

3) In calculus, there are many ways to calculate the derivative of a function. Let's assume a function, y ax +bxc. We know that the standard derivative of the function is 2ax+b However, we also know that the derivative can also be found through the equation de = Inn y(r + 1)-y(x) Known as the definition of the derivative Your program should 1. Accept integer coefficients for the second order polynomial equation 2. Display the equations for the polynomial and the standard derivative 3. Accept a value of x 4. Evaluate the derivative at x using the first method 5. Using the second method, decreasing orders of h (begin at 0.1, work your way down to 0.000001) and a loop, create a table of the values of the derivative at x and the difference between the value calculated using the standard derivative (the first method) and the definition of a derivative (the second method) am execution sample Enter coefficients for the second order polynomial: 1 23 Your equation is 1xA2+2x+3 and its derivative is 2x+2. Enter a value for x: dy/dx=2.200000 h=0.1 00000, dy/dx=2.300000, diff 0.100000 h=0.010000, dy/dx=2.209997, diff-0.009997 h=0.001000, dy/dx=2.201081, diff-0.001081 h=0.000100, dy/dx=2.200604, diff=-0.000604

Explanation / Answer

derivative.c

#include <stdio.h>

int main()
{
   int a,b,c;
   double x;
   printf("enter the coefficients of second order polynomial ");
   scanf("%d",&a);
   scanf("%d",&b);
   scanf("%d",&c);

   printf("You equation is %dx^2+%dx+%d and its derivative is %dx+%d Enter a value for x: ",a,b,c,2*a,b);

   scanf("%lf",&x);
   double d=2*a*x+b;
   printf("dy/dx = %f ",d);
   double diff=0,d2=0;

double h=0.1;
   for(h=0.1;h>=0.000001;h=h/10)
   {
       //c will automatically cancel in f(x+h)-f(x) so not taking it into account in the equation below
       d2=(a*((x+h)*(x+h)-x*x)+b*h)/h;
       diff=d-d2;
       printf("h = %f, dy/dx = %1.6f, diff = %f ",h,d2,diff);
   }
   return 0;
}