Search code examples
rplotexp

How to plot exp-functions using r


I want to plot two e-functions (in a single graph) using R:

a) f(t)=20(1-e^(-0,1t))

b) f(t)=0,4t(t+7)e^(-0,1t)

I tried the curve() function but I don't know how to use it with e-functions.

Could you help me please? Thanks!


Solution

  • If you look at the help file of ?curve, you can find many clues, e.g.

    chippy <- function(x) sin(cos(x)*exp(-x/2))
    curve(chippy, -8, 7, n = 2001)
    

    which would, in your case, translate to

    f1 <- function(t) 20 * (1-exp(-0.1 * t))
    curve(f1, from = -10, to = 20)
    

    I'll let you figure out how to do the second one.