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 Quote 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; Quote 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 Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/247462-php-give-calculating-mistake/#findComment-1270801 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.