Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Definite Integral Calculation

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
lkhiger

New User


Joined: 28 Oct 2005
Posts: 89

PostPosted: Sat Sep 26, 2009 7:42 am    Post subject: Definite Integral Calculation
Reply with quote

Definite Integral interval [a, b]: Sf(x)dx = G(b) - G(a) where G'(x) = f(x) , or differential of G(x) = f(x).

Integrals appear in many practical situations.
Consider a swimming pool. If it is rectangular, then from its length, width, and depth we can easily determine the volume of water it can contain (to fill it), the area of its surface (to cover it), and the length of its edge (to rope it).

But if it is oval with a rounded bottom, all of these quantities call for integrals. Practical approximations may suffice for such trivial examples, but precision engineering (of any discipline) requires exact and rigorous values for these elements.

I create the query which calculate integral of 3 * X^2 - 2 * X in interval [2, 4]....

S(3 * X^2 - 2 * X)dx = X^3 - X^2 and exact value of integral will be
S = (4^3 - 4^2) - (2^3 - 2^2) = 48 - 4 = 44.

We know nothing in our solution about exact value and differential and suppose to calculate approximate value of integral.
Process will stop when the absolute difference between current value of integral and previous become less or equal some eps real number.

Code:
With
Source (Xstart, Xfinish, imgFunc, eps) as
(select double(2), double(4), '3 * X^2 - 2 * X', double(1.e-3)
   from sysibm.sysdummy1
)
,
Integral_calc (Xs, Xf, Xc, step, curint, prevint, eps, iterno) as
(select Xstart, Xfinish, double(Xstart - (Xfinish - Xstart) / 10.) Xc,
                double((Xfinish - Xstart) / 10.) step,  double(0), double(0), eps, int(0)
 from Source
union All
select Xs, Xf, Xc + step, step, curint + Fc * step, prevint, eps, iterno + 1
  from Integral_calc, table
(select 3 * power(Xc + step, 2) - 2 * (Xc + step) Fc
   from sysibm.sysdummy1 ) it
where  Xc + step <= Xf
Union All
select Xs, Xf, Xs - (step / 2.), step / 2., 0., curint, eps, iterno + 1
  from Integral_calc
where Xc + step > Xf
  and abs(curint - prevint) > eps
)
,
Integral(integral_value, integral_image) as
(select curint, 'interval: [' || varchar(Xs) || ', ' || varchar(Xf) || ']:  S' || '('
                              || imgFunc || ')dx = ' || varchar(round(curint, 3))   
from Integral_calc, Source
where iterno = (select max(iterno) from Integral_calc)
)
select integral_value, integral_image from Integral


Result of calculation:

Quote:
INTEGRAL_VALUE............................ INTEGRAL_IMAGE
4.40005859378289E+001............... interval: [2.0E0, 4.0E0]: S(3 * X^2 - 2 * X)dx = 4.4001E1


Could be very useful for students and engineers.

Lenny
Back to top
View user's profile Send private message

lkhiger

New User


Joined: 28 Oct 2005
Posts: 89

PostPosted: Sat Sep 26, 2009 7:45 am    Post subject: Notes...
Reply with quote

This query is working fast for short intervals.

Do not use it for intervals with length > 10....

Also, if you want calculate yours integral, you have to change:


Code:
table (select 3 * power(Xc + step, 2) - 2 * (Xc + step) Fc
   from sysibm.sysdummy1 ) it


and

Code:
Source (Xstart, Xfinish, imgFunc, eps) as
(select double(1), double(12), '3 * X^2 - 2 * X', double(1.e-3)
   from sysibm.sysdummy1


Lenny
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts MSU calculation for DB2 (to decide be... SRICOBSAS DB2 4 Wed Mar 23, 2016 6:07 pm
No new posts Time difference calculation Ramsee COBOL Programming 8 Wed Dec 10, 2014 3:15 pm
No new posts Date calculation thru SORT card. bshkris SYNCSORT 3 Tue Jul 08, 2014 1:56 pm
No new posts &MAXSIZE parameter value calculat... vini m JCL & VSAM 12 Thu Feb 20, 2014 5:02 pm
No new posts Percentage Calculation in SYNCSORT mistah kurtz SYNCSORT 11 Wed Nov 20, 2013 7:47 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us