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

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 /

[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)

Re: [R] gmp::bigq vs. MASS::fractions

2023-01-07 Thread Ivan Krylov
On Sat, 7 Jan 2023 17:29:35 +0100 Sigbert Klinke wrote: > > x <- (0:7)/7 > > > MASS::fractions(x) > > [1] 0 1/7 2/7 3/7 4/7 5/7 6/7 1 > > > gmp::as.bigq(x) > > Big Rational ('bigq') object of length 8: > > [1] 0 > 2573485501354569/18014398509481984

[R] gmp::bigq vs. MASS::fractions

2023-01-07 Thread Sigbert Klinke
Hi, has someone experience which routine should be used for creating fractional numbers? The two conversion routines deliver different results > x <- (0:7)/7 > MASS::fractions(x) [1] 0 1/7 2/7 3/7 4/7 5/7 6/7 1 > gmp::as.bigq(x) Big Rational ('bigq') object of length 8: [1] 0