Run Code

API

Code Wall

Users

Misc

Feedback

Login

Theme

Privacy

Patreon
derivative
//g++ 7.4.0 //derivative function //credit for derivative function code goes to John R Hubbard, University of Richmond; other function and test driver codes are created by Rezaul Hoque on July 23,2021; contact: jewelmrh@yahoo.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <iostream> #include <cmath> using namespace std; double derivative (double (*) (double),double,double); double sroot(double); double expo(double ); double sroot(double b){// sqrt() defined in cmath does the same thing return(pow(b,0.5)); } double expo(double t){//exp() defined in cmath does the same thing return(pow(2.71818,t)); } double derivative (double (*pf)(double t), double x, double h){ return ((*pf)(x+h)  (*pf)(xh))/(2*h); } int main(){ cout<<derivative (sroot,4,0.001)<<endl; cout<<derivative (sin,0.5236,0.001)<<endl; cout<<derivative (expo,0,0.001)<<endl; cout<<derivative (log,1,0.01)<<endl; return 0; }
run

edit

history

help
0
Please
log in
to post a comment.
DP Optimization another kind
TemplateRemove
Smart Pointers
tes
Estocasticos V1.1
Float
Zahra_matrix
RCP 27
Round prices
const example
Please log in to post a comment.