Real Numbers are those number who have fractional part also with the integer part. The computer can calculate power of integer only. So here is the solution that how fractional power can be calculated using the computer languages.
According to problem we have to calculate the a^b where b is real number. When b is a whole number the computer just multiply the a with itself for b times and generate a result of a^b.
But when b is real number of fractional number the computer generate a error.
Here is Simple Solution of this problem:
Let us assume
x = a^b
or log x = b * log a
or x = e ^ ( b * log a )
The computer can calculate both exponential and logarithmic values of real numbers by using series expansion method. hence by using this algo we can easily calculate the value of any real number raise to real number.
Now here comes another problem that log a will never exists if a is less than zero. So the algo fails when we have to calculate the power of real number less than 0 or equal zero. Equal zero condition is automatically forbidden by the native language data types, because in all languages real number doesn't have precise zero.
so we have to add condition to this algo, that when a<0 then convert the sign of a and then calculate the power after that return the negative value of result.
When we put this condition into account then another problem rises that it will return the square root of negative number as negative and equal to square root of positive number. Hence we have to check the b if the value of b is not such that it is calculating the square root of any negative number.
One solution of this problem is that check whether the reversal of b is divisible by 2, if it is then generate an error that result is imaginary.