[R] Integrate two function in R

David Winsemius dwinsemius at comcast.net
Thu Dec 16 14:30:48 CET 2010


On Dec 16, 2010, at 7:27 AM, Alaios wrote:

> Hello I have two function in R
> like
> g(x)=2x-3
> and s(x)=5x^2+2
>
> and I want to find the integrafl of the g(x)*s(x) inside the  
> interval of [a,b]
>
> Could you please help me find the proper function?

It depends on what you are doing:

None of what appears below is valid R code. Finding the closed form  
expression for the integral of a third degree polynomial evaluated at  
a and b would be a simple first semester calculus problem. It's not  
clear why you are using R for this.

And if someone has posed this to you as a homework problem in hopes  
that you will find a way to get a polynomial solution in terms of a  
and b then you need to look at the RYacas package. R has some limited  
symbolic differentiation tools but I do not remember seeing any  
symbolic integrations within R.

So if you were think of using not a and b but rather specific numbers  
for a numeric solution, then the integrate function is the obvious  
choice. If you don't understand what the help page for "integrate"  
says, then perhaps you should explain at what point you are getting  
stuck. Bring code next time.


>
> I would like to thank you in advance for your help
>
> Regards
> Alex

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list