Re: [R] Problem with integrate(function(x) x^3 / sin(x), -pi/2, pi/2)

2023-01-07 Thread Ivan Krylov
On Sun, 8 Jan 2023 05:24:05 +0200 Leonard Mada via R-help wrote: > pracma::integral(function(x) x^3 / sin(x), -pi/2, pi/2 ) > # 3.385985 Note that at least one implementation used by pracma::integral has the same problem: pracma::integral(function(x) x^3/sin(x), -pi/2, pi/2, no_intervals=7) # [

Re: [R] Problem with integrate(function(x) x^3 / sin(x), -pi/2, pi/2)

2023-01-07 Thread Andrew Simmons
`subdivisions` is the maximum number of subintervals. Looking here https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/src/appl/integrate.c#L1275 I'm not surprised that changing `subdivisions` has no effect on the outcome. The integration method from {pracma} might work,

Re: [R] Problem with integrate(function(x) x^3 / sin(x), -pi/2, pi/2)

2023-01-07 Thread Andrew Simmons
You're dividing 0 by 0, giving you NaN, perhaps you should try function(x) ifelse(x == 0, 0, x^3/sin(x)) On Sat, Jan 7, 2023, 22:24 Leonard Mada via R-help wrote: > Dear List-Members, > > I encounter a problem while trying to integrate the following function: > > integrate(function(x) x^3 / sin

[R] Problem with integrate(function(x) x^3 / sin(x), -pi/2, pi/2)

2023-01-07 Thread Leonard Mada via R-help
Dear List-Members, I encounter a problem while trying to integrate the following function: integrate(function(x) x^3 / sin(x), -pi/2, pi/2) # Error in integrate(function(x) x^3/sin(x), -pi/2, pi/2) : #  non-finite function value # the value should be finite: curve(x^3 / sin(x), -pi/2, pi/2) int

Re: [R] Problem with integrate function

2013-04-03 Thread S Ellison
>Error in integrate(fx[[2]], 0.056, 1) : > maximum number of subdivisions reached > > Can anyone help? At the risk of longer integration time, look at the 'subdivisions' argument in ?integrate and consider increasing it? S Ellison

[R] Problem with integrate function

2013-04-03 Thread Swagato Chatterjee
Hello, The following code of mine is giving the error: Error in integrate(fx[[2]], 0.056, 1) : maximum number of subdivisions reached Can anyone help? Thanks and Regards. Swagato -- fv<-vector("list") fx<-vector("list") v<-0 c<-0 n<-0 NOV<-0 i<-0 while(n<200){ fv[