help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: plotting even function


From: John B. Thoo
Subject: Re: plotting even function
Date: Sun, 20 Mar 2005 13:25:23 -0800

First, thanks to Geraint B, Mike M, Avraham for their replies.

On Mar 20, 2005, at 9:09 AM, Geraint Paul Bevan wrote:

For symmetry about the y-axis, you therefore require that:
(-1)^(1/n) = -1.

However, for n=3, y=(-1)^(1/n) has three solutions:
 y = -1
 y = 0.5+i*sqrt(3)/2
 y = 0.5-i*sqrt(3)/2

You obviously want to use the first of these solutions to get symmetry
about the y-axis but Octave doesn't know that unless you tell it.

So, am I now right then in thinking that if z = r * (cos t + i * sin t), then Octave will return z^(1/n) = r^(1/n) * (cos (t/n) + i * sin (t/n))?


And on Mar 20, 2005, at 10:52 AM, Geraint Paul Bevan added:

$ g++ a.cc && ./a.out
+1^2.0  1
- -1^2.0        1
+1^0.5  1
- -1^0.5        nan

As you can see from the results above, the double version of pow cannot
cope with a negative base and non-integer exponent. Therefore in this
case Octave uses the Complex (i.e. complex<double>) version of pow. It
is this routine which is finding complex solutions for negative x
instead of the real root that would be required for symmetry about the
y-axis.

I think I have a better understanding now. Of course, I know that I want the real root :-O but it never occurred to me that Octave wouldn't use the real root if there is one. Duh!

So, if you would allow me at least one more daft question, how do I tell Octave to use the real root so that the plot of y = x^(1/3) is symmetrical about the origin?

TIA.
---John.



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]