[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

1590.0. "Numerical integration among math packages" by CIV009::LYNN (Lynn Yarbrough @WNP DTN 427-5663) Wed Apr 01 1992 21:09

One of the examples in the textbook for Mathematica is to compute the 
numerical integral (to 40 places) of sin(exp(x)) from 0 to 1. Getting the 
right result is something of a challenge:

Math'a text:	.8749571987803839994388329808353131568824

MapleV:		.8749571987803840302385072720264325057257
                                                   20
Math'a V1.2:	.87495719878038403023851 + 1.648*10   *I

It appears that the text is based on an earlier and inferior algorithm, but
how significant is the error implied by the complex term in V1.2? Is the
MapleV result correct, and to how many places? 

Anyone have any suggestions about getting a more reliable result? (No, 
there is no closed form for this integral.)
T.RTitleUserPersonal
Name
DateLines
1590.1an easy oneGAUSS::ROTHGeometry is the real life!Thu Apr 02 1992 00:1433
    I don't think it's difficult at all - it's a very well
    behaved integrand with no singularities on the interval, so
    that even simple-minded Romberg integration (extrapolation to the
    limit via the asymptotic error term from trapezoidal integration)
    will converge, as shown by the following sequence of approximations
    in VAX H precision:

 subdiv fncalls    approx                           error estimate
 ------ ---- -----------------------------------    --------------
    2     3  0.626126137655402601064255906824330    0.247226      
    3     5  0.873352304294445890170144033002492    1.832444E-0003
    4     9  0.875184748795601088023570336288850    2.266590E-0004
    5    17  0.874958089701637284335865903154165    8.968199E-0007
    6    33  0.874957192881641013304750745339498    5.892269E-0009
    7    65  0.874957198773910750800636856996653    6.474081E-0012
    8   129  0.874957198780384832026717863989211    8.015067E-0016
    9   257  0.874957198780384030520000990857232    2.814897E-0019
   10   513  0.874957198780384030238511216019147    3.944041E-0024
   11  1025  0.874957198780384030238507271977611    4.882136E-0029
   12  2049  0.874957198780384030238507272026433    9.629649E-0035

Math'a text: 0.8749571987803839994388329808353131568824

MapleV:	     0.8749571987803840302385072720264325057257

   Mathematica is not to be trusted for any serious work in my opinion -
   I've heard too many stories about bad answers coming out of it.

   Which is scary, actually - to hear educators talk, students don't even
   know how to do simple arithmetic.  How are they going to sanity check
   the stuff coming out of some algebra system???

    - Jim
1590.2GAUSS::ROTHGeometry is the real life!Thu Apr 02 1992 02:303
    By the way, is the base note in keeping with the first of April?

    (like the posting about the world's smallest prime number recently)
1590.3tough problemSTAR::ABBASIi^(-i) = SQRT(exp(PI))Thu Apr 02 1992 02:4316
i think that is a good question, but it applies to software in general.

May be we can use similar idea as in hardware fault tolerant architecture, 
send the input through 3 modules, compare the output from the 3,
if one is different from the other two output, you know something is most
    likely wrong with that one that produced a different output, replace that 
    module.

this is what Jim did in .1, checked the output from maple and from 
a third independent program, found the maple and the VAX output to 
be closest to each other, then there is a good chance that mma output is
the wrong one. 

/nasser

    
1590.4you will always need math to do mathSGOUTL::BELDIN_RPull us together, not apartThu Apr 02 1992 12:0624
   Re:         <<< Note 1590.1 by GAUSS::ROTH "Geometry is the real life!" >>>

>   Which is scary, actually - to hear educators talk, students don't even
>   know how to do simple arithmetic.  How are they going to sanity check
>   the stuff coming out of some algebra system???

answer:

   You must examine your assumption that somehow these things
   will be tools to help non-initiates do mathematics.  They are
   not and will not be magic boxes that eliminate the need for
   education.  Worse (for the egalitarians), they put more
   (intellectual) power in the hands of those who already have
   it.  The prognosis is for widening the breach between the
   have's and have-not's in the intellectual sphere.  Basically,
   the need for students to know their math is greater, not
   less, in the computer age.
   
Dick

   ps.
   
   Note that it is no longer the 1st of April.  I'm very serious
   about this.
1590.5simple answerGAUSS::ROTHGeometry is the real life!Fri Apr 03 1992 05:3651
    It just occurred to me that it was brain dead to try and numerically
    integrate this problem when all you really have to do is freshman
    calculus...

    Change the variable x in the integrand to u = log(x)

	sin(exp(x)) dx = sin(u)/u du

    and it's the integral from 1 to e.

    Expanding this in a series and integrating term by term we find

	f(u) = u - u^3/(3*3!) + u^5/(5*5!) - ...

    so the integral is f(e)-f(1) as the following program shows.

    - Jim

	PROGRAM APRIL_FOOLS

	IMPLICIT REAL*16 (A-H,O-Z)

	X = 1
	CALL MTH$HEXP(E, X)
	CALL SINX(X, S1)
	CALL SINX(E, SE)

	TYPE *, S1, SE, SE-S1

	END

	SUBROUTINE SINX(X, S)

	IMPLICIT REAL*16 (A-H,O-Z)

	S = 0
	T = 1
	X2 = -X*X
	DO I = 1,100000,2
	  STMP = S
	  S = S+T/I
	  IF (STMP.EQ.S) GOTO 100
	  T = T*X2/((I+1)*(I+2))
	ENDDO
100	CONTINUE

	S = S*X

	RETURN

	END