Search code examples
rplotcurve

Plotting curve of f(α) = (α2 + 1)^(0.5) for t between 0 and 5, using MML to annotate graphic


I need to plot a curve of f(α) = (α2 + 1)^(0.5) for t between 0 and 5, using MML to annotate graphic. Any help would be appreciated, Thanks.

So far I have two options the first shows a curve without the Function annotated at the top. This is with extra parentheses in the comments.

curve((x^2 + 1)^(0.5), from=0, to=5,
      xlab = expression(alpha),
      ylab = expression((alpha^2 + 1)^(0.5), # ((alpha
      main = expression(paste("Function : ",
                              f(alpha) == (alpha^2 + 1)^(0.5))))) # ))

Output: Curve plot of the program

When I exclude the parentheses commented above one before the alpha and the matching one. I think I would get the annotated function at the top of the curve.

curve((x^2 + 1)^(0.5), from=0, to=5,
      xlab = expression(alpha),
      ylab = expression(alpha^2 + 1)^(0.5),
      main = expression(paste("Function : ",
                              f(alpha) == (alpha^2 + 1)^(0.5))))

The program doesn't run and gives me this error.

Error in expression(alpha^2 + 1)^(0.5) : 
  non-numeric argument to binary operator

Solution

  • I think it may just be placement of parentheses. This should work:

    curve((x^2 + 1)^(0.5), from=0, to=5,
          xlab = expression(alpha),
          ylab = expression((alpha^2 + 1)^(0.5)), 
          main = expression(paste("Function : ", f(alpha) == (alpha^2 + 1)^(0.5))))