Skip to content

Instantly share code, notes, and snippets.

@pureexe
Created December 13, 2017 07:19
Show Gist options
  • Select an option

  • Save pureexe/80b2b7c1810b49c3c7f3065d042d58ef to your computer and use it in GitHub Desktop.

Select an option

Save pureexe/80b2b7c1810b49c3c7f3065d042d58ef to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<math.h>
double f(double x,double h){
return (sin(x+h)-sin(x))/h;
}
int main(){
double h = 1 / pow(2,16);
double a1 = (4*f(1,h) - f(1,2*h))/3;
printf("cos(1) = %.12f \nd/dx sin(1) = %.12f",cos(1),a1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment