Post Reply 
WP 34S solve an integral
04-24-2015, 06:37 PM (This post was last modified: 04-24-2015 07:20 PM by Dieter.)
Post: #23
RE: WP 34S solve an integral
(04-24-2015 06:22 PM)Thomas_Sch Wrote:  A beginners question:
Where in Barry's program (...) should I insert your lines ?

The rounding is done at the very end of the function routine, right before the result is returned to SLV:

Code:
LBL A
STO 00      //Save target integral result desired
DROP        //Lower stack to get Upper/Lower solve guess bounds
SLV 00
RTN
ERR 20      //If solve fails to find a root show this error
LBL 00
 0
∫ 01      // ∫ from x to 0 = –∫ from 0 to x 
RCL+ 00   // 10 – ∫
RDP 05    // round to e.g. 5 decimal places
x≠0?      // if result does not round to zero
x<> L     // recall the original unrounded value
RTN
LBL 01

RTN

However, limiting the execution time of the Integrate function is much more important. Here the number of iterations depends on the display setting. So be sure to set something like SCI 4 or FIX 5. There is not much sense in having the integral calculated to 12 digits when finally 10 – this is rounded to 5 digits. ;-)

Remember: the execution time of Integrate is directly influenced by the display setting. The result is returned as soon as it matches display precision. On the other hand, Solve always tries to return a full-accuracy result, no matter which display format is set. That's why speeding up Solve requires manual rounding.

Addendum: in this particular case it would make sense to have Solve quit at the same accuracy level as Integrate, i.e. as soon as the result rounded to the current display setting becomes zero. This can be done with a simple ROUND command (rounds to display precision, unliike RDP that rounds to the number of specified digits). Or, even more elegant, use the dedicated x≈0? test which directly tests whether the display-rounded value of x is zero:

Code:
...
LBL 00
 0
∫ 01      // ∫ from x to 0 = –∫ from 0 to x 
RCL+ 00   // 10 – ∫
x≈0?      // if result rounds to zero
CLx       // then return zero
RTN
...

Now simply set FIX 4 or FIX 5 and you're done.

Please note that x≈0? is useless in display modes other than FIX. So don't use SCI, ENG or ALL here.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
WP 34S solve an integral - lrdheat - 04-23-2015, 07:27 PM
RE: WP 34S solve an integral - lrdheat - 04-23-2015, 08:43 PM
RE: WP 34S solve an integral - BarryMead - 04-23-2015, 08:50 PM
RE: WP 34S solve an integral - BarryMead - 04-23-2015, 09:05 PM
RE: WP 34S solve an integral - Dieter - 04-24-2015, 12:34 PM
RE: WP 34S solve an integral - BarryMead - 04-24-2015, 02:46 PM
RE: WP 34S solve an integral - CR Haeger - 04-23-2015, 10:28 PM
RE: WP 34S solve an integral - BarryMead - 04-23-2015, 10:34 PM
RE: WP 34S solve an integral - Dieter - 04-23-2015, 10:46 PM
RE: WP 34S solve an integral - walter b - 04-24-2015, 08:57 AM
RE: WP 34S solve an integral - CR Haeger - 04-24-2015, 01:24 PM
RE: WP 34S solve an integral - Dieter - 04-24-2015, 12:16 PM
RE: WP 34S solve an integral - CR Haeger - 04-24-2015, 01:01 PM
RE: WP 34S solve an integral - Dieter - 04-24-2015, 01:09 PM
RE: WP 34S solve an integral - rprosperi - 04-24-2015, 05:53 PM
RE: WP 34S solve an integral - Thomas_Sch - 04-24-2015, 06:22 PM
RE: WP 34S solve an integral - Dieter - 04-24-2015 06:37 PM
RE: WP 34S solve an integral - Dieter - 04-25-2015, 10:48 AM
RE: WP 34S solve an integral - BarryMead - 04-25-2015, 06:59 PM
RE: WP 34S solve an integral - Dieter - 04-25-2015, 08:54 PM
RE: WP 34S solve an integral - lrdheat - 04-24-2015, 02:11 AM
RE: WP 34S solve an integral - Thomas_Sch - 04-24-2015, 06:19 AM
RE: WP 34S solve an integral - CR Haeger - 04-24-2015, 01:20 PM
RE: WP 34S solve an integral - Thomas_Sch - 04-24-2015, 07:07 PM
RE: WP 34S solve an integral - Dieter - 04-24-2015, 07:17 PM
RE: WP 34S solve an integral - Thomas_Sch - 04-24-2015, 07:30 PM
RE: WP 34S solve an integral - walter b - 04-24-2015, 10:12 PM
RE: WP 34S solve an integral - Thomas_Sch - 04-24-2015, 10:27 PM
RE: WP 34S solve an integral - lrdheat - 04-25-2015, 09:09 PM



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