#' plot
#'
#' Plots the parabolas created in a Trapezoid rule
#' numerical integration.
#'
#' @param Trapezoid The Trapezoid object to plot.
#' @export
setMethod("plot",
signature="Trapezoid",
definition=function(x=NULL, y=x, ...){
plot(x=NULL, y=NULL, xlim=range(x@x), ylim=range(x@y), xlab="x", ylab="y", main="Numerical Integration (Trapezoid Method)")
points(x@x, x@y, pch=16)
# There is one fewer dot than the length of the range,
# because the range is bordered by lines.
line.range = 1:length(x@x)
dot.range = 1:length(x@x - 1)
segments(x@x[dot.range], x@y[dot.range], x@x[dot.range+1], x@y[dot.range+1])
segments(x@x[line.range], 0, x@x[line.range], x@y[line.range])
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.