# WordPress.org

## Calculated Fields Form[resolved] Can't make mathematical form work (3 posts)

1. OliverEggertsen
Member
Posted 1 year ago #

Hi.

I am having a problem with making my mathematical formula "work".

I am making a formula of a simple future value calculation.

The formula is: Present value * (1 + interest/100)^number of time periods.

I have entered this formula in my calculated field:
PREC(POW(fieldname4*(1+fieldname2/100),fieldname3),2)

Fieldname 4 is present value
Fieldname 2 is interest
Fieldname 3 is number of time periods

If i for example enter 100 in present value, 2 in interest, and 20 in time periods i get a huge number compared to the real answer which should be 148.59

2. codepeople
Member
Plugin Author

Posted 1 year ago #

Hi,

Please, replaces the fields names, by the initial numbers in your current equation:

If the present value is 100, and the interes is 2, and the number of time periods is 20, your equation would be:

PREC(POW(100*(1+2/100),20),2) = PREC(POW(102,20),2)

and

102^20 = 1.4859473959783544e+40

PREC(POW(1.4859473959783544e+40),2) = 1.4859473959783544e+40

So, if you're obtaining a huge number as equation's result with the initial values you sent me, the equation is working fine.

Now, if you modify the equation like follow:

PREC(fieldname4*POW((1+fieldname2/100),fieldname3),2)

you will get the result you want ;-)

Remember, you should create the equations maintaining the priorities between the operations of the Mathematical world.

Best regards.

3. OliverEggertsen
Member
Posted 1 year ago #

Thanks :-)

This topic has been closed to new replies.