c# - Why does Math.Pow(-78.0921, -64.6294) return NaN? -


i have 2 values: x = -78.0921 , y = -64.6294. now, when want compute math.pow(x, y) returns nan. should do? how can solve problem?

how should calculate power? there other function can calculate this?...or maybe not defined mathematically ?

you've tried compute number not real.

by not real mean, if tried every single number between largest number , smallest number can think of, none of numbers solution -78.0921 power of -64.6294.

in fact, no real number solution -1 power of 0.5, or square root of -1, , in general a^b if negative , b non-integer, the result not real.

the inability express such useful result in real numbers lead invention of complex numbers. sqrt(-1) = i, imaginary unit, in complex number system - complex numbers have real component , imaginary component, expressed a + b*i.

in general, no negative number fractional power produces real result, have component of in - closer .5 power is, more i, closer .0, more real, , path follows circle between real , imaginary, e.g.

-1^x = cos(pi*x)+i*sin(pi*x)

read more complex numbers: http://en.wikipedia.org/wiki/complex_number


if wish work complex numbers in c#, try http://msdn.microsoft.com/en-us/library/system.numerics.complex.aspx

however, unless complex numbers have meaning in problem domain (they meaningful in many electrical engineering, physics , signal analysis problems, example) it's possible data wrong or logic wrong attempting such thing in first place.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -

jquery - How can I dynamically add a browser tab? -