Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include "stdafx.h"
  2.  
  3. #include <vector>
  4.  
  5.  
  6. double ackley(double x)
  7. {
  8.    
  9.     double f = 0.8;
  10.     double a = 20;
  11.     double e = exp(1);
  12.     double b = 0.2;
  13.     double n = 2;
  14.     double c = 2 * 3.14;
  15.     double d = 5.7;
  16.     double sum1 = -a * exp(-b*sqrt(1 / n*(pow(x, 2))));
  17.     double sum2 = exp(1 / n *cos(e*x)) + a + e + d;
  18.     double fu = 1/f*(sum1- sum2);
  19.     return fu ;
  20.  
  21. }
  22.  
  23. int _tmain(int argc, _TCHAR* argv[])
  24. {
  25.     for (double i = -32; i < 32; i+=0.02)
  26.     printf("%f \n", ackley(i));
  27.     return 0;          
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement