Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

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