I can plot this just fine:
t<-seq(0,4, by=.1)
y<- t^3-6*t^2+5*t+30
plot(t,y ,xlab="t-values", ylab="f(t)", type="l")
This is the first derivative, how I I make a similar plot?
t<-seq(0,4, by=.1)
y<- t^3-6*t^2+5*t+30
y1<-D(expression(t^3-6*t^2+5*t+30), 't')

Thanks ahead of time.

kc






On Fri, Jan 22, 2010 at 12:41 PM, Doran, Harold <hdo...@air.org> wrote:

> > D(expression(t^3-6*t^2+5*t + 30), 't')
> 3 * t^2 - 6 * (2 * t) + 5
>
> > D(D(expression(t^3-6*t^2+5*t + 30), 't'), 't')
> 3 * (2 * t) - 6 * 2
>
> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Marlin Keith Cox
> Sent: Friday, January 22, 2010 4:37 PM
> To: r-help@r-project.org
> Subject: [R] first and second derivative calculation
>
> I would like to calculate a first and second derivative and am having
> problems finding a simple solution.  My syntax may be off as I am not a
> mathematician, so pardon ahead of time.
> data:
> t<-seq(0,4, by=.1)
> The function is:
> H(t) = t^3-6*t^2+5*t + 30
>
> from here I plot the curve:
> plot(x,y ,xlab="x-values", ylab="f(x)", type="l")
> But would like to similarly plot the curve for both the first and second
> derivatives.
> I can calculate the derivatives by hand but would like to get R to do this
> for me.
> by hand:
> H'(t) = 3*t^2 - 12*t + 5
> H''(t) = 6*t-12
> Keith
>
> --
> M. Keith Cox, Ph.D.
> Alaska NOAA Fisheries, National Marine Fisheries Service
> Auke Bay Laboratories
> 17109 Pt. Lena Loop Rd.
> Juneau, AK 99801
> keith....@noaa.gov
> marlink...@gmail.com
> U.S. (907) 789-6603
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
M. Keith Cox, Ph.D.
Alaska NOAA Fisheries, National Marine Fisheries Service
Auke Bay Laboratories
17109 Pt. Lena Loop Rd.
Juneau, AK 99801
keith....@noaa.gov
marlink...@gmail.com
U.S. (907) 789-6603

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to