Graphing mathematical functions

Sometimes, you may wish to plot a mathematical function. We have already seen how to do that, but the curve() command provides a nice alternative. Let's plot a cubic curve using the curve() command. To use curve(), you must specify a function within the parentheses. Enter the following syntax:

curve(5*x**3 + 6*x**2 - 5, -2, 2 , col = "blue", main = "CUBIC CURVE")

The following is our graph:

Graphing mathematical functions

We have a smooth cubic curve and the axis limits we specified within the code. The curve() command allows you to specify a function as the first argument, the range of values over which you wish to create your graph, and add your graph to an already existing graph. See the R help function for the curve() command by entering ?curve() on the command line.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset