why coding this function returns un exact numerical results?
2 views (last 30 days)
Ackley's Function (a=20,b=0.2) d=2.
function [ y ] = objfun14 (phen )
v=cos(2*pi*phen); x=(1/d)* sum(v,2);
t=-20*exp(-0.2*sqrt((1/d)*sum(phen.^2,2))) - exp( x ) +20+exp(1);
%when phen=[0 0] the output should be t=0 however excuting the code gives t=8.8818e-16
Kishan Dhakan on 23 Jun 2021
Try using 'format long', which shows 15 decimal places. If it still doesn't work, then your value is probably smaller than what many call 'machine epsilon' and hence is getting rounded to zero.