help-octave
[Top][All Lists]
Advanced

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

Re: Why is 2/3 not seen as rational? [was "plotting even function"]


From: Paul Kienzle
Subject: Re: Why is 2/3 not seen as rational? [was "plotting even function"]
Date: Mon, 21 Mar 2005 08:04:02 -0500


On Mar 20, 2005, at 11:00 AM, John B. Thoo wrote:

On March 19, 2005 4:20:04 PM PST I wrote:

Hi.  I hope that I'm not embarrassing myself by asking the following.

I believe that

       3       2/3    1
  y = --- (2 x)    + ---
       4              2

is an even function

And on Mar 19, 2005, at 12:36 PM, Thomas Shores replied:

Here's the problem: how do you know that the exponent is a
rational fraction, so that you can reinterpret it?  Octave
rightfully doesn't.

I don't understand why 2/3 is not seen as rational. At first I thought it may be because division by 3 results in a nonterminating decimal, but then I found that plotting x^(2/5) gives the same (formerly) unexpected result as plotting x^(2/3) (not symmetrical about the y-axix). So, why is m/n not seen as rational?

The cubed root function is multi-valued and Octave is choosing
a different root than you expect.  Look at -8 for example:

x^3 + 8 has three roots:

  octave> roots([1,0,0,8])
  ans =

  -2.0000 + 0.0000i
   1.0000 + 1.7321i
   1.0000 - 1.7321i

Octave chooses one of them:

  octave> (-8).^(1/3)
  ans = 1.0000 + 1.7321i

And it is indeed a root:

  octave> ((-8).^(1/3)).^3
  ans = -8.0000e+00 + 2.2204e-15i

This is the root used when computing -8^2/3

  octave> (-8).^(2/3)
  ans = -2.0000 + 3.4641i

  octave> ((-8).^(1/3)).^2
  ans = -2.0000 + 3.4641i

And it is a correct solution, with (-8^2/3)^3 == -8^2

  octave> ((-8).^(2/3)).^3
  ans = 6.4000e+01 - 2.6042e-14i


- Paul



-------------------------------------------------------------
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]