I am having a problem converting an excel maths function to a php function, I have the majority of the code correct, however the last bit I cannot seem to get correct.
This is the excel function
=SUM((0.75*200000)*(1+(0.04/12))^(5*12))-(((0.04/12)*(0.75*200000)/((1-(1+(0.04/12))^(-(30*12)))))/(0.04/12))*((1+(0.04/12))^(5*12)-1)
This is my PHP code
((0.75*200000)*(pow(1+(0.04/12),(5*12)))) - (((0.04/12)*(0.75*200000) / (1-(pow(1+(0.04/12),-(30*12)))))/(0.04/12)) * (pow((1+(0.04/12)),(5*12)-1)) ;
At the moment my PHP code is getting the answer of -78,294.13 I need to get 135,671
I believe that the following code is wrong, but I cant seem to figure out why.
(pow((1+(0.04/12)),(5*12)-1))
Any help would be much appreciated.
You have error in PHP calculation:
... * (pow((1+(0.04/12)),(5*12)-1)) ;
should be:
... * (pow((1+(0.04/12)),(5*12))-1) ;