# HP Forums

Full Version: Quiz: calculating a definite integral
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
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

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.
I would use Excel and evaluate using the trapezoidal rule.

Regards,

John
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
I do believe the program should be:

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

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
(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$$

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.
(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
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.
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
(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:-)
(12-31-2013 08:54 AM)walter b Wrote: [ -> ]As the WP 34S does.
Wer hat's erfunden?
(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 ?
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.
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
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
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
Plot the function, cut out the plot and use your trusty weighing scale to calculate the area. A chemist's scale shall do.

d:-)
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...
(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
(12-31-2013 01:29 PM)Paul Dale Wrote: [ -> ]hatchet planimeters are easy to construct.

They are so cool!
(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
(01-01-2014 10:31 PM)Thomas Klemm Wrote: [ -> ]What's $$\exp(t)$$?

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

SCNR
Pages: 1 2 3
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :