invictor Posted September 19, 2011 Share Posted September 19, 2011 $test1 = exp(-((-4.00)^2)/2)/(sqrt(2*pi(1))); //prints 1.08443755142 echo $test1; I need advise with this math formula, it prints 1.08443755142 but THIS IS WRONG! it should be: 0.0001338302 (which i both confirmed via excel, wolframalpha, matlab, google) Any idea? I getting grey hair! Best regards Invictor Link to comment https://forums.phpfreaks.com/topic/247462-php-give-calculating-mistake/ Share on other sites More sharing options...
xyph Posted September 19, 2011 Share Posted September 19, 2011 Have you checked on your arithmetic operators lately? http://php.net/manual/en/language.operators.arithmetic.php What exactly does '^' do? $v = exp( -pow(-4,2)/2 ) / sqrt( 2*pi() ); echo $v; Link to comment https://forums.phpfreaks.com/topic/247462-php-give-calculating-mistake/#findComment-1270787 Share on other sites More sharing options...
ManiacDan Posted September 19, 2011 Share Posted September 19, 2011 Damn, beaten to it. ^ is a logical XOR pow() is the function for doing exponents. -Dan Link to comment https://forums.phpfreaks.com/topic/247462-php-give-calculating-mistake/#findComment-1270788 Share on other sites More sharing options...
invictor Posted September 19, 2011 Author Share Posted September 19, 2011 Hahaha, thanks :-[ :-[ :-[ :-[ :-[ :-[ :-[ and no i didnt spend 5 hours on this Link to comment https://forums.phpfreaks.com/topic/247462-php-give-calculating-mistake/#findComment-1270801 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.