HP Forums
Quiz: calculating a definite integral - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Quiz: calculating a definite integral (/thread-284.html)

Pages: 1 2 3


Quiz: calculating a definite integral - Thomas Klemm - 12-30-2013 09:37 PM

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.


RE: Quiz: calculating a defined integral - John Smitherman - 12-30-2013 10:46 PM

I would use Excel and evaluate using the trapezoidal rule.

Regards,

John


RE: Quiz: calculating a defined integral - W_Max - 12-30-2013 11:44 PM

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


RE: Quiz: calculating a defined integral - Namir - 12-31-2013 04:24 AM

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


RE: Quiz: calculating a defined integral - Thomas Klemm - 12-31-2013 04:56 AM

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


RE: Quiz: calculating a defined integral - Thomas Klemm - 12-31-2013 06:37 AM

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



RE: Quiz: calculating a defined integral - Paul Dale - 12-31-2013 07:13 AM

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


RE: Quiz: calculating a defined integral - walter b - 12-31-2013 08:54 AM

(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:-)


RE: Quiz: calculating a defined integral - Thomas Klemm - 12-31-2013 09:14 AM

(12-31-2013 08:54 AM)walter b Wrote:  As the WP 34S does.
Wer hat's erfunden?


RE: Quiz: calculating a defined integral - walter b - 12-31-2013 10:12 AM

(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


RE: Quiz: calculating a defined integral - peacecalc - 12-31-2013 10:24 AM

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.


RE: Quiz: calculating a defined integral - peacecalc - 12-31-2013 10:57 AM

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


RE: Quiz: calculating a defined integral - Thomas Klemm - 12-31-2013 01:14 PM

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


RE: Quiz: calculating a defined integral - Paul Dale - 12-31-2013 01:29 PM

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


RE: Quiz: calculating a defined integral - walter b - 12-31-2013 02:16 PM

Plot the function, cut out the plot and use your trusty weighing scale to calculate the area. A chemist's scale shall do.

d:-)


RE: Quiz: calculating a defined integral - peacecalc - 12-31-2013 02:20 PM

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...


RE: Quiz: calculating a defined integral - Thomas Klemm - 12-31-2013 05:55 PM

(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


RE: Quiz: calculating a defined integral - Thomas Klemm - 12-31-2013 06:01 PM

(12-31-2013 01:29 PM)Paul Dale Wrote:  hatchet planimeters are easy to construct.



They are so cool!


RE: Quiz: calculating a definite integral - Thomas Klemm - 01-01-2014 10:31 PM

(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


RE: Quiz: calculating a definite integral - walter b - 01-02-2014 08:11 AM

(01-01-2014 10:31 PM)Thomas Klemm Wrote:  What's \( \exp(t) \)?

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

SCNR Wink