Post Reply 
Problem with integral on WP 34s
09-08-2021, 01:43 AM
Post: #1
Problem with integral on WP 34s
Am I doing something wrong (quite possibly), or am I encountering a bug on the WP 34S?

The integral from -2 to 3 of 1/(3ROOT X) should equal ~.739 (My WP 34S comes up with 0).

I used the following:

LBL ‘F0’
FILL
3ROOT
1/X
RTN

I tried several other alternative programs, and they all produced “0”.
Find all posts by this user
Quote this message in a reply
09-08-2021, 02:07 AM
Post: #2
RE: Problem with integral on WP 34s
What a strange. I type your program 'F0' on emulator and got 0.72406877411. My keystroke is this.

Code:
(suppose you entered F0 program)
2
+/-
ENTER
3
g
2 (integral)
ENTER
CPX (for enter F)
0
ENTER

S.Korean / HP-50G | fx-570EX | fx-570CW | HP-200LX
Visit this user's website Find all posts by this user
Quote this message in a reply
09-08-2021, 03:48 AM
Post: #3
RE: Problem with integral on WP 34s
That is strange! I tried it on my iPad emulator, and on my DM 42 with the WP 34 loaded into the unit.

My iPad emulated is 34S 3.3T 3913

I’m running the program now on my HP 30b that was converted into a WP 34S, and the integral is taking a long time to converge (perhaps 25 minutes into the integration), and it may be converging on the correct answer. The DM 42, and the IPad 34S 3.3T 3913 quickly produce “0”.

I will let the HP 30b converted unit continue to run a while longer. After it finishes (or I give up), I will check it’s version of the WP 34S software.
Find all posts by this user
Quote this message in a reply
09-08-2021, 04:33 AM
Post: #4
RE: Problem with integral on WP 34s
My HP 30b WP 34S is version 3.3 3774. It gave up at the .724+ answer.
Find all posts by this user
Quote this message in a reply
09-08-2021, 04:35 AM
Post: #5
RE: Problem with integral on WP 34s
Curious as to if my WP 34S DM 42 and iPad versions do in fact, have a bug.
Find all posts by this user
Quote this message in a reply
09-08-2021, 05:50 AM (This post was last modified: 09-08-2021 05:57 AM by toml_12953.)
Post: #6
RE: Problem with integral on WP 34s
(09-08-2021 01:43 AM)lrdheat Wrote:  Am I doing something wrong (quite possibly), or am I encountering a bug on the WP 34S?

The integral from -2 to 3 of 1/(3ROOT X) should equal ~.739 (My WP 34S comes up with 0).

I used the following:

LBL ‘F0’
FILL
3ROOT
1/X
RTN

I tried several other alternative programs, and they all produced “0”.

Is that 1/(x^(3/2)) ? If so, the answer is 1.387+1.139 i

https://www.integral-calculator.com/

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
09-08-2021, 06:12 AM
Post: #7
RE: Problem with integral on WP 34s
(09-08-2021 04:35 AM)lrdheat Wrote:  Curious as to if my WP 34S DM 42 and iPad versions do in fact, have a bug.

I get 0 on the iPad but the correct value on the OSX emulator. The source code should be the same as far as I know (and I should know as I wrote them) but the firmware version is different.
Unfortunately, I do not have the programming environment nor the time to debug it.
Find all posts by this user
Quote this message in a reply
09-08-2021, 07:11 AM
Post: #8
RE: Problem with integral on WP 34s
(09-08-2021 03:48 AM)lrdheat Wrote:  That is strange! I tried it on my iPad emulator, and on my DM 42 with the WP 34 loaded into the unit.

My iPad emulated is 34S 3.3T 3913

I’m running the program now on my HP 30b that was converted into a WP 34S, and the integral is taking a long time to converge (perhaps 25 minutes into the integration), and it may be converging on the correct answer. The DM 42, and the IPad 34S 3.3T 3913 quickly produce “0”.

I will let the HP 30b converted unit continue to run a while longer. After it finishes (or I give up), I will check it’s version of the WP 34S software.

I used Windows emulator.

(09-08-2021 05:50 AM)toml_12953 Wrote:  
(09-08-2021 01:43 AM)lrdheat Wrote:  Am I doing something wrong (quite possibly), or am I encountering a bug on the WP 34S?

The integral from -2 to 3 of 1/(3ROOT X) should equal ~.739 (My WP 34S comes up with 0).

I used the following:

LBL ‘F0’
FILL
3ROOT
1/X
RTN

I tried several other alternative programs, and they all produced “0”.

Is that 1/(x^(3/2)) ? If so, the answer is 1.387+1.139 i

https://www.integral-calculator.com/

I think it is 1/(x^(1/3)), Wolfram Alpha gives 4.31068-2.06209 i
https://www.wolframalpha.com/input/?i2d=...om+-2+to+3

S.Korean / HP-50G | fx-570EX | fx-570CW | HP-200LX
Visit this user's website Find all posts by this user
Quote this message in a reply
09-08-2021, 11:28 AM
Post: #9
RE: Problem with integral on WP 34s
(09-08-2021 06:12 AM)pascal_meheut Wrote:  I get 0 on the iPad but the correct value on the OSX emulator. The source code should be the same as far as I know (and I should know as I wrote them) but the firmware version is different.
Unfortunately, I do not have the programming environment nor the time to debug it.

There might not be a bug to debug.
Most integration routine assumed no singularity within integral limits.
(this is especially true for double-exponential integration, with sample points mostly on the edges)

Convergence is based on previous estimate, not true result.
(if we do know true result, there is no need to integrate ...)

If we are lucky, "converged" result is close to true result.
Unfortunately, we don't know how good the result really is.
If not, routine may give up (thus the 0.0 result)

We should break up integral to peices. In this case, surd(x,3) is odd function:

∫(1/surd(x,3), x=-2 .. +3) = ∫(x^(-1/3), x=+2 .. +3) = preval(x^(2/3)/(2/3), 2, 3) ≈ 0.7390
Find all posts by this user
Quote this message in a reply
09-08-2021, 11:49 AM
Post: #10
RE: Problem with integral on WP 34s
(09-08-2021 07:11 AM)BINUBALL Wrote:  
(09-08-2021 03:48 AM)lrdheat Wrote:  That is strange! I tried it on my iPad emulator, and on my DM 42 with the WP 34 loaded into the unit.

My iPad emulated is 34S 3.3T 3913

I’m running the program now on my HP 30b that was converted into a WP 34S, and the integral is taking a long time to converge (perhaps 25 minutes into the integration), and it may be converging on the correct answer. The DM 42, and the IPad 34S 3.3T 3913 quickly produce “0”.

I will let the HP 30b converted unit continue to run a while longer. After it finishes (or I give up), I will check it’s version of the WP 34S software.

I used Windows emulator.

(09-08-2021 05:50 AM)toml_12953 Wrote:  Is that 1/(x^(3/2)) ? If so, the answer is 1.387+1.139 i

https://www.integral-calculator.com/

I think it is 1/(x^(1/3)), Wolfram Alpha gives 4.31068-2.06209 i
https://www.wolframalpha.com/input/?i2d=...om+-2+to+3

"3 root" is the cube root but "3root" = x^(3/2)

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
09-08-2021, 02:03 PM
Post: #11
RE: Problem with integral on WP 34s
Doing the integral in parts is certainly a much better solution to a problem such as this!
Find all posts by this user
Quote this message in a reply
09-11-2021, 06:14 PM
Post: #12
RE: Problem with integral on WP 34s
More poor results, this with an endpoint. While the HP 30b unit converted to a WP 34S does fine, the WP 34S app for iPad produces an infinity error as does the WP 34S on the DM 42. Having the 1/0 occur at an endpoint precludes doing the integral in parts.

The integral from 0 to pi for 1/sqrt(1+cos(x)) (radian mode) should be 2*sqrt(2)~=2.8284

The HP 42S does fine as does the Free 42 app on my iPad.

The iPad and DM 42 versions of WP 34S should be used with caution for these types of problems.
Find all posts by this user
Quote this message in a reply
09-11-2021, 08:28 PM
Post: #13
RE: Problem with integral on WP 34s
Thanks to Albert Chan for pointing out my typo.

The integral is from 0 to pi of (sin (x))/sqrt (1+cos(x)).
Find all posts by this user
Quote this message in a reply
09-12-2021, 04:00 PM
Post: #14
RE: Problem with integral on WP 34s
(09-11-2021 06:14 PM)lrdheat Wrote:  More poor results, this with an endpoint. While the HP 30b unit converted to a WP 34S does fine, the WP 34S app for iPad produces an infinity error as does the WP 34S on the DM 42. Having the 1/0 occur at an endpoint precludes doing the integral in parts.

The integral from 0 to pi for 1/sqrt(1+cos(x)) (radian mode) should be 2*sqrt(2)~=2.8284

The HP 42S does fine as does the Free 42 app on my iPad.

The iPad and DM 42 versions of WP 34S should be used with caution for these types of problems.

Try setting Flag D - this allows for infinite or NAN results without halting program execution. Quoting from the integrate.wp34s xrom code file:
Quote:// - if the user has set the D flag, many errors when evaluating the
// integrand (say 0/0 or 1/0, overflows or ...) will not raise an error,
// but return infinite or NaN instead. Such conditions will be detected
// by this program that will continue the computation simply ignoring
// the offending point
On doing this, I get 2.8284 on my DM42 WP34S for your integral.

Nigel (UK)
Find all posts by this user
Quote this message in a reply
09-12-2021, 04:16 PM
Post: #15
RE: Problem with integral on WP 34s
A little more information: the integration routine was changed to the double exponential method in release 3893. To save people poking about in the code, here are the complete comments from the integration code file:
Quote:// Double Exponential Integration for the wp34s calculator
//
// v1.4x-412 (20180312) by M. César Rodríguez GGPL
//
// USAGE:
// Inputs:
// - integration limits in X (upper limit) and Y (lower limit)
// Outputs:
// - approximate value of integral in X
// - estimated error in Y
// - upper integration limit in Z
// - lower integration limit in T
// - updates L (with upper limit)
// - in SSIZE8 mode, all ABCD will be corrupted
//
// Remarks:
// - accepts +Infinite and -Infinite as integration limits. If none
// of the limits is infinite, the method applied is the tanh-sinh
// one. If both are infinite then the sinh-sinh method is selected.
// Otherwise the exp-sinh method is used
// - the program tries to get all displayed digits correct, so
// increasing the number of displayed digits will (hopefully) give
// closer approximations (needing more time). But, in DBLON mode, the
// program ignores the number of displayed digits and does its best
// to get as much correct digits as possible
// - during program execution the succesive aproximations are
// displayed (as with the built-in integration program). Pressing
// [<-] will interrupt the program & the last approximation
// will be returned. The estimated error will be 0 in this case
// - if the computed error estimation is not much smaller than the computed
// result, it is assumed that all digits of the result are corrupted by
// roundoff. In such cases, the reported result is 0 and the reported
// error estimation equals the sum of the absolute values of the computed
// result and error. This usually happens when the integral evaluates to 0
// - if the user has set the D flag, many errors when evaluating the
// integrand (say 0/0 or 1/0, overflows or ...) will not raise an error,
// but return infinite or NaN instead. Such conditions will be detected
// by this program that will continue the computation simply ignoring
// the offending point
// - keep in mind that, when both integration limits are infinite (or
// one is infinite and the other 0) the integrand may be evaluated
// at really bigs/small points (up to 1e±199 in DBLOFF mode and
// 1e±3088 in DBLON mode). Ensure that your integrand program
// behaves as expected for such arguments (you may consider to set
// flag D in some circumstances)
// - the double exponential method relies on the function to be
// integrated being analytic over the integration interval, except,
// perhaps, at the interval ends. Thus, if it is known that the
// integrand, _or any of its derivatives_, has a discontinuity at some
// point inside the integration interval, it is advised to break the
// interval at such point and compute two separate integrals, one
// at each side of the problematic point. Better results will be
// get this way. Thus, beware of abs, fp, ip and such non analytic
// functions inside the integrand program. Other methods (Romberg)
// may behave better in this respect, but, on the other side, the
// double exponential method manages discontinuities (of the
// integrand or its derivatives) at the interval edges better and
// is usually way faster that the Romberg method
// - as many other quadrature methods (Romberg included), the
// double exponential algorithm does not manage well highly
// oscillatory integrands. Here, highly oscillatory means that the
// integrand changes sign many (or infinite) times along the
// integration interval
//
// Method used:
// The algorith used here is adapted from that described in:
// H. Takahasi and M. Mori. "Double Exponential Formulas for Numerical
// Integration." Publications of RIMS, Kyoto University 9 (1974),
// 721-741.
// Another useful reference may be:
// David H. Bailey, Xiaoye S. Li and Karthik Jeyabalan, "A comparison
// of three high-precision quadrature schemes," Experimental
// Mathematics, vol. 14 (2005), no. 3, pg 317-329.
//
// 264 steps
// 16 local registers

Nigel (UK)
Find all posts by this user
Quote this message in a reply
09-12-2021, 07:56 PM
Post: #16
RE: Problem with integral on WP 34s
Wow! Thanks, Nigel! That worked.
Find all posts by this user
Quote this message in a reply
09-12-2021, 08:10 PM
Post: #17
RE: Problem with integral on WP 34s
Nigel...is there any downside that I should be aware of with flag D set?
Find all posts by this user
Quote this message in a reply
09-12-2021, 08:41 PM
Post: #18
RE: Problem with integral on WP 34s
Glad it helped!

With flag D set, 1/0 is returned as infinity and the square root of -5 is NaN (when not using CPX). I don't think that this is a problem when working from the keyboard, but it does mean that a program that would be halted by an error will continue to run when Flag D is set. If a program's logic relies on it being halted by an error, this could be a problem.

The first integral above
\[\int_{-2}^3x^{-1/3}\,{\rm d}x\]
still doesn't work properly even with Flag D set. The comments from the integration code state that
Quote:the double exponential method relies on the function to be
integrated being analytic over the integration interval, except,
perhaps, at the interval ends
and so, with this integration method, the problem is unavoidable. The comments also suggest that the Romberg method might be better in this respect, but would in general be slower. Do you think it would be helpful to provide the old Romberg code as an alternative for situations like this?

Nigel (UK)
Find all posts by this user
Quote this message in a reply
09-12-2021, 08:53 PM
Post: #19
RE: Problem with integral on WP 34s
I do think that alternate methods would be great to have...unlikely I would imagine on the HP 30b due to limited space, but would be welcome on the DM 42 and iPad versions. How do I find the +Infinity/-infinity choices on the DM 42 version of WP 34S?
Find all posts by this user
Quote this message in a reply
09-12-2021, 09:28 PM
Post: #20
RE: Problem with integral on WP 34s
I have no control over the iPad version, but I'll look at adding the older Romberg method to the DM42.

To enter \(+\infty\) or \(-\infty\) on the DM42, do shift shift 5 to bring up the constants menu. Press up-arrow 3 or 4 times, and you'll find them.

Nigel (UK)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)