I am trying to code and algorithm that can allow me to calculate power of a function with decimal exponent. The language that I am using to code in doesn't has any predefined power functions.
I already have a simple formula coded which allows me to calculate power of a function with non-decimal exponents.
I don't necessarily need a generalized solution. I only need to find value of a number raised to the power 2.4.
I tried to break down my problem as follows:
x ^ (2.4) = (x ^ 2) * (x ^ 0.4) = (x ^ 2) * (x ^ (2/5)) = (x ^ 2) * ((x ^ 2) ^ 1/5)
Finding square of x can be done, so my problem breaks down to calculating the "5th root" of a number.
I also thought of breaking my problem into a logarithmic equation but didn't reached anywhere with that.
I am thinking of writing a code implementing the long-divison method of calculating roots but that seems highly inefficient and non-elegant.
Can anyone suggest me a more simpler and efficient way of solving my problem? If not, then has anyone tried coding the long-divison method of calculating roots?
Thanx in advance!!
Note: this is a template that i would be using many many times in my execution so efficiency is all the more important for me.