Re: [R] Graphing the Area of Definite Integral

2015-12-16 Thread peter dalgaard
> On 16 Dec 2015, at 22:09 , David Winsemius wrote: > >>> and look watch the graphs. >> >> Looks fine to me, at least the non-plotmath version? > > Here's a plotmath version that positions the expression in the center of the > plot region. Just in case: I wasn't implying an issue with the pl

Re: [R] Graphing the Area of Definite Integral

2015-12-16 Thread David Winsemius
> On Dec 16, 2015, at 12:24 PM, peter dalgaard wrote: > > >> On 16 Dec 2015, at 20:58 , Steven Stoline wrote: >> >> Dear David: >> >> >> could you please try it for the functions f(x)=x^2 from -4 to 4 and the >> function f(x) = sqrt(x) from 0 to 4, and look watch the graphs. > > Looks fin

Re: [R] Graphing the Area of Definite Integral

2015-12-16 Thread Steven Stoline
Dear David: could you please try it for the functions *f(x)=x^2* from *-4* to *4* and the function *f(x) = sqrt(x)* from *0* to *4*, and look watch the graphs. Thank you very much for your helps. steve On Wed, Dec 16, 2015 at 2:09 PM, David Winsemius wrote: > > > On Dec 16, 2015, at 9:00

Re: [R] Graphing the Area of Definite Integral

2015-12-16 Thread peter dalgaard
> On 16 Dec 2015, at 20:58 , Steven Stoline wrote: > > Dear David: > > > could you please try it for the functions f(x)=x^2 from -4 to 4 and the > function f(x) = sqrt(x) from 0 to 4, and look watch the graphs. Looks fine to me, at least the non-plotmath version? -pd > > > Thank you very

Re: [R] Graphing the Area of Definite Integral

2015-12-16 Thread David Winsemius
> On Dec 16, 2015, at 9:00 AM, Steven Stoline wrote: > > Dear William: *Left and Right Riemann Sums* > > > Is there is a way to modify your function to compute Left Riemann Sum and > Right Riemann Sum. I tried to modify yours, but i was not be able to make > it work correctly. > > This is you

Re: [R] Graphing the Area of Definite Integral

2015-12-16 Thread Steven Stoline
Dear William: *Left and Right Riemann Sums* Is there is a way to modify your function to compute Left Riemann Sum and Right Riemann Sum. I tried to modify yours, but i was not be able to make it work correctly. This is your function used to compute the Middle Riemann Sum. showIntegral.med <-

Re: [R] Graphing the Area of Definite Integral

2015-12-16 Thread William Dunlap via R-help
showIntegral <- function (f, xmin, xmax, n = 16, fractionFromLeft = 0.5) { stopifnot(fractionFromLeft >= 0, fractionFromLeft <= 1, n >= 1) curve(f(x), from = xmin, to = xmax, lwd = 2, col = "blue") abline(h = 0) dx <- (xmax - xmin)/n right <- xmin + (1:n) * dx left <

Re: [R] Graphing the Area of Definite Integral

2015-12-01 Thread Steven Stoline
Dear Bill: It looks great. many thanks *one more quick help:* how to graph only the x and y axis crossing through the origin, with xlim=c(-1,1,0.2) and ylim=c(0,1,0.2)? with many thanks steve On Sat, Nov 28, 2015 at 1:11 PM, William Dunlap wrote: > Your right <- (1:n)*dx mean that yo

Re: [R] Graphing the Area of Definite Integral

2015-11-28 Thread William Dunlap
Your right <- (1:n)*dx mean that your leftmost rectangle's left edge is at 0, but you want it to be at -4. You should turn this into a function so you don't have to remember how the variables in your code depend on one another. E.g., showIntegral <- function (f, xmin, xmax, n = 16) { curve(

Re: [R] Graphing the Area of Definite Integral

2015-11-28 Thread Steven Stoline
Dear Peter: in my previous email I forgot to reply to the list too I used your code for more than one examples, and it works nicely. But when I tried to use for the the function: f(x) = x^2, it looks like I am missing something, but I could not figured it out. This what I used: f <- function(x

Re: [R] Graphing the Area of Definite Integral

2015-11-27 Thread Steven Stoline
many thanks steve On Fri, Nov 27, 2015 at 9:20 AM, peter dalgaard wrote: > Something like this? > > f <- function(x) x^3-2*x > curve(f(x), from=0, to=4) > abline(h=0) > n <- 16 > dx <- 4/n > right <- (1:n)*dx > left <- right - dx > mid <- right - dx/2 > fm <- f(mid) > points(mid, fm) > rect(lef

Re: [R] Graphing the Area of Definite Integral

2015-11-27 Thread peter dalgaard
Something like this? f <- function(x) x^3-2*x curve(f(x), from=0, to=4) abline(h=0) n <- 16 dx <- 4/n right <- (1:n)*dx left <- right - dx mid <- right - dx/2 fm <- f(mid) points(mid, fm) rect(left,0,right,fm) sum(fm*dx) 1/4 * 4^4 - 4^2 -pd On 27 Nov 2015, at 13:52 , Steven Stoline wrote:

Re: [R] Graphing the Area of Definite Integral

2015-11-27 Thread Ben Tupper
Hi Steve, Give RSeek.org a try ... http://rseek.org/?q=show+area+under+curve There a loads of examples and blogs on this topic at RSeek.org. Under the 'Support' tab there is an exchange between two USM folk on this very topic. Cheers, Ben On Nov 27, 2015, at 7:52 AM, Steven Stoline wrote: