Skip to content

Plot f(x) = x^(1/5)

10 messages · Steven Stoline, Mark Daniel Ward, jim holtman +3 more

#
Dear All:


I am trying to plot the function f(x) = x^(1/5) for x=seq(-2,2,0.01). It
give me only the plot of f(x) for the positive part of x. I checked the
values of f(x), it is NaN for all negative values of x.

*this is my code:*


x<-seq(-2,2,0.01)
y<- (x)^(1/5)
plot(x,y, type="l", lwd=3, xlab = " ", ylab = " ", col="blue")
abline(v=0, col="gray", lty=2, lwd=3)
abline(h=0, col="gray", lty=2, lwd=3)



any help will be appreciated.


with many thanks
steve
#
Dear Steven,

Well, the values x^(1/5) are complex-valued (not real-valued) when x is 
negative.

Did you want to plot the absolute value of x^(1/5) instead?

Mark

Mark Daniel Ward, Ph.D.
Associate Professor and Undergraduate Chair
Department of Statistics
Purdue University
150 North University Street
West Lafayette, IN 47907-2067
mdw at purdue.edu
phone: (765) 496-9563
On 5/17/16 8:44 AM, Steven Stoline wrote:
#
System is working correctly.  A negative number cannot be raised to a
fractional power:
[1] NaN




Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Tue, May 17, 2016 at 8:44 AM, Steven Stoline <sstoline at gmail.com> wrote:

            

  
  
#
Dear All:

in my TI-Calculator (-0.5)^(1/5) = -0.8705, but in R  (-0.5)^(1/5) = NaN.


with thanks
steve
On Tue, May 17, 2016 at 8:52 AM, jim holtman <jholtman at gmail.com> wrote:

            

  
    
#
Try this:

 y <- sign(x) * abs(x)^(1/5)
On Tue, May 17, 2016 at 8:44 AM, Steven Stoline <sstoline at gmail.com> wrote:

  
    
#
Try :

-0.5^(1/5)
[1] -0.8705506

David

-----Original Message-----
From: R-sig-teaching [mailto:r-sig-teaching-bounces at r-project.org] On Behalf Of Steven Stoline
Sent: 17 May 2016 14:07
To: jim holtman <jholtman at gmail.com>
Cc: R-sig-teaching <r-sig-teaching at r-project.org>
Subject: Re: [R-sig-teaching] Plot f(x) = x^(1/5)

Dear All:

in my TI-Calculator (-0.5)^(1/5) = -0.8705, but in R  (-0.5)^(1/5) = NaN.


with thanks
steve
On Tue, May 17, 2016 at 8:52 AM, jim holtman <jholtman at gmail.com> wrote:

            
--
Steven M. Stoline
1123 Forest Avenue
Portland, ME 04112
sstoline at gmail.com


_______________________________________________
R-sig-teaching at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-teaching

________________________________


This email may have a protective marking please see http://www.mrc.ac.uk/about/information-standards/document-marking-policy/ <http://www.mrc.ac.uk/about/information-standards/document-marking-policy/>

This email and any attachments are intended for the name...{{dropped:21}}
#
Dear Gabor:

many thanks,makes it.

steve

On Tue, May 17, 2016 at 9:07 AM, Gabor Grothendieck <ggrothendieck at gmail.com

  
    
#
this is where you should be using parenthesis to make sure you have the
correct precedence of operations:
[1] -0.8705506
[1] NaN
[1] NaN
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Tue, May 17, 2016 at 9:09 AM, David Pell <David.Pell at mrc-hnr.cam.ac.uk>
wrote:
1 day later
#
Dear All:


can someone please help me to plot the *Folium of Descrates:**  x^3+y^3=3xy
for x<-seq(-5,5,0.010) and **y<-seq(-5,5,0.010) *
<https://www.google.com/search?biw=1155&bih=597&q=R:+Folium+of+Descartes&spell=1&sa=X&ved=0ahUKEwiBrsnWpeTMAhUFKB4KHU5TD0EQvwUIGSgA>


with thanks
steve

On Tue, May 17, 2016 at 9:07 AM, Gabor Grothendieck <ggrothendieck at gmail.com

  
    
#
Use the t-parametrized form from e.g.,
http://mathworld.wolfram.com/FoliumofDescartes.html

t <- seq(-50, 50, by=0.01)
x <- 3*t/(1+t^3)
y <- 3*t^2/(1+t^3)
plot(x, y, xlim=c(-5, 5), ylim=c(-5, 5), type="l")

(I'm limiting the plot to avoid the huge values that occur near t=-1)

MW
On Wed, May 18, 2016 at 1:58 PM, Steven Stoline <sstoline at gmail.com> wrote: