Guest User

Untitled

a guest
Jan 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. // the actual functions come from particle physics and are extremely ugly
  2. double f(double x){
  3. return 2*x+1;
  4. }
  5. //in reality a numerical derivative term
  6. double F(const std::function<double(double)>& f, double x){
  7. return f(x) - f(x+1);
  8. }
  9. // in reality another higher order numerical derivative
  10. double G(const std::function<double(double)>& f, double x){
  11. return f(x) + f(x+1);
  12. }
  13. // in reality a function where the index is supposed to control the degree of derivatives of the function
  14. double H(const std::function<double(double)>& f, double x, int switch){
  15. if(0 == switch){
  16. return G(f(x));
  17. } else {
  18. return F(f(x));
  19. }
  20. }
  21.  
  22. double sum=0;
  23. for(int i=0; i<1;++i){
  24. for(int j=0; j<1;++j){
  25. sum += H(H(f,i),j);
  26. }
  27. }
Add Comment
Please, Sign In to add comment