Post Reply 
Quiz: calculating a definite integral
12-30-2013, 09:37 PM (This post was last modified: 01-02-2014 05:43 PM by Thomas Klemm.)
Post: #1
Quiz: calculating a definite integral
Let's assume we want to calculate the following definite integral:
\[ \int_{0}^{1}x^{-x}dx \]
We'd use a calculator with an \( \int_{x}^{y} \) button and write a short program:

01 LBL 0
02 CHS
03 \(y^x\)
04 RTN

The result is something like: 1.291285997
Now what if for some reason this button doesn't work or we don't have a calculator that supports numerical integration?
How can we still calculate this definite integral?

Cheers
Thomas

Addendum:
How can I guide you into the right direction without spoiling the quiz?
Of course you can just use another calculator where the button isn't broken.
But that's not the point of this quiz.
Find all posts by this user
Quote this message in a reply
12-30-2013, 10:46 PM
Post: #2
RE: Quiz: calculating a defined integral
I would use Excel and evaluate using the trapezoidal rule.

Regards,

John
Find all posts by this user
Quote this message in a reply
12-30-2013, 11:44 PM (This post was last modified: 12-30-2013 11:46 PM by W_Max.)
Post: #3
RE: Quiz: calculating a defined integral
Well... It depends on what machine we have. Even plain TI-55 can calculate this, using primitive rectangle method. But I prefer Simpson's if it can fit in program memory, of course Smile
Find all posts by this user
Quote this message in a reply
12-31-2013, 04:24 AM (This post was last modified: 12-31-2013 04:29 AM by Namir.)
Post: #4
RE: Quiz: calculating a defined integral
I do believe the program should be:

Code:
01 LBL 0
02 ENTER
03 CHS
04 yx
05 RTN

For the built-in integral to work! your answer is correct!

Now to answer your question. I would use an open Newton-Cote numerical integration method since this class of methods do not evaluate the integral at the end points, just in case my machine barks at evaluating 1/0^0.

Namir
Find all posts by this user
Quote this message in a reply
12-31-2013, 04:56 AM (This post was last modified: 12-31-2013 08:58 AM by Thomas Klemm.)
Post: #5
RE: Quiz: calculating a defined integral
(12-31-2013 04:24 AM)Namir Wrote:  I do believe the program should be:

Code:
01 LBL 0
02 ENTER
03 CHS
04 yx
05 RTN

For the built-in integral to work!
The HP-15C conveniently fills the stack with \(x\) when calling your function.

Quote:I would use an open Newton-Cote numerical integration method since this class of methods do not evaluate the integral at the end points, just in case my machine barks at evaluating 1/0^0.

Good point. The function is continuous even at 0: \(\lim_{x\to0}x^{-x}=1\)
[Image: attachment.php?aid=87]
But the first derivative is singular at 0: \(\lim_{x\to0}\frac{\partial x^{-x}}{\partial x}=\infty\)
HP's modified Romberg method avoids the end-points of the interval as well.
Find all posts by this user
Quote this message in a reply
12-31-2013, 06:37 AM
Post: #6
RE: Quiz: calculating a defined integral
(12-30-2013 11:44 PM)W_Max Wrote:  Well... It depends on what machine we have. Even plain TI-55 can calculate this, using primitive rectangle method. But I prefer Simpson's if it can fit in program memory, of course Smile
I've tried Valentin's Gaussian integration for the HP-11C for various values of N:

   10: 1.291303564
   20: 1.291290482
   50: 1.291286729
  100: 1.291286183
  200: 1.291286042
  500: 1.291286006
 1000: 1.291285997

He doesn't seem to be fond of Simpson's rule:
Quote:Simpson's method is to numerical integration what bubble sort is to sorting, i.e., vastly inefficient.
Find all posts by this user
Quote this message in a reply
12-31-2013, 07:13 AM
Post: #7
RE: Quiz: calculating a defined integral
Interesting is the suggestion that a Gaussian method would have been used in the 34C if there were ROM space. I originally used such a method in the 34S and almost everyone wanted it changed to an adaptive one instead (Romberg).


- Pauli
Find all posts by this user
Quote this message in a reply
12-31-2013, 08:54 AM
Post: #8
RE: Quiz: calculating a defined integral
(12-31-2013 04:56 AM)Thomas Klemm Wrote:  The HP-15C conveniently fills the stack with \(x\) when calling your function.

As the WP 34S does.

d:-)
Find all posts by this user
Quote this message in a reply
12-31-2013, 09:14 AM
Post: #9
RE: Quiz: calculating a defined integral
(12-31-2013 08:54 AM)walter b Wrote:  As the WP 34S does.
Wer hat's erfunden?
Find all posts by this user
Quote this message in a reply
12-31-2013, 10:12 AM
Post: #10
RE: Quiz: calculating a defined integral
(12-31-2013 09:14 AM)Thomas Klemm Wrote:  
(12-31-2013 08:54 AM)walter b Wrote:  As the WP 34S does.
Wer hat's erfunden?
Du nicht, ich nicht, aber vielleicht die Entwickler des HP-34C ? Wink
Find all posts by this user
Quote this message in a reply
12-31-2013, 10:24 AM (This post was last modified: 12-31-2013 10:51 AM by peacecalc.)
Post: #11
RE: Quiz: calculating a defined integral
Hello Thomas,

If I use fix 4 on the hp 15c (the very old version no LE) I get in some seconds a correct result (like N=20, some posts above), that shows the algorithem functions well.

Maybe the problems by fix 9 are caused by calculating the integrand: instead of \[ x^{-x} \] as \[ \exp(-x\cdot\ln(x)) \]. That have a great alteration rate near zero. The hp 15c algorithem don't calculate at the limits the value of the integrand, but for getting a higher precision it runs into a great number of calculations.

Sincerely
peaceglue

P.S. I have to correct myself, even with 0.01 or 0.1 it doesn't come to an end.
Find all posts by this user
Quote this message in a reply
12-31-2013, 10:57 AM
Post: #12
RE: Quiz: calculating a defined integral
Hello all,

now the result for the limits 0,1 and 1 take a few minutes: 1,176021571 (fix 9). But that's not a resonable duration. In fix 4 it takes some seconds.

Sincerely
peacecalc
Find all posts by this user
Quote this message in a reply
12-31-2013, 01:14 PM
Post: #13
RE: Quiz: calculating a defined integral
It takes 2'27" to calculate this integral on a DM-15CC with FIX 9.
It takes 28" to do it with the RPN-15C emulator on my iPhone.
On a real HP-15C it takes probably much longer.
Can you do it much faster?

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
12-31-2013, 01:29 PM
Post: #14
RE: Quiz: calculating a defined integral
Plot the function, print out the plot and use your trusty planimeter to calculate the area. If you are unlucky enough to not own a planimeter, hatchet planimeters are easy to construct.


- Pauli
Find all posts by this user
Quote this message in a reply
12-31-2013, 02:16 PM
Post: #15
RE: Quiz: calculating a defined integral
Plot the function, cut out the plot and use your trusty weighing scale to calculate the area. A chemist's scale shall do.

d:-)
Find all posts by this user
Quote this message in a reply
12-31-2013, 02:20 PM
Post: #16
RE: Quiz: calculating a defined integral
Hello Thomas,

it is allowed to calculate without a calc with an approximation? But then I never can beat 28'', therefore I'm to slow...
Find all posts by this user
Quote this message in a reply
12-31-2013, 05:55 PM
Post: #17
RE: Quiz: calculating a defined integral
(12-31-2013 02:20 PM)peacecalc Wrote:  Hello Thomas,

it is allowed to calculate without a calc with an approximation? But then I never can beat 28'', therefore I'm to slow...
Sure! Use whatever you like. I used paper and pencil first. And only then the calculator and was down at 1".

Best regards
Thomas
Find all posts by this user
Quote this message in a reply
12-31-2013, 06:01 PM
Post: #18
RE: Quiz: calculating a defined integral
(12-31-2013 01:29 PM)Paul Dale Wrote:  hatchet planimeters are easy to construct.



They are so cool!
Find all posts by this user
Quote this message in a reply
01-01-2014, 10:31 PM
Post: #19
RE: Quiz: calculating a definite integral
(12-31-2013 10:24 AM)peacecalc Wrote:  calculating the integrand: instead of \( x^{-x} \) as \( \exp(-x\cdot\ln(x)) \)
That's a step into the right direction.
What's the next? What's \( \exp(t) \)?

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
01-02-2014, 08:11 AM
Post: #20
RE: Quiz: calculating a definite integral
(01-01-2014 10:31 PM)Thomas Klemm Wrote:  What's \( \exp(t) \)?

\( \exp(t) = e^{t}\).

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




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