Lecture_notes_summary2

Lecture_notes_summary2 - Chapter 2 Program Elements We seek...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 2 Program Elements We seek in this section to solve mathematical problems of the type quadrature. I = b a f ( x ) dx N 1 ± i =0 f ( x i ) δ, for the left hand rule. In order to compute this integral approximation, we need to decide the discretization rule for the x i ’s, for instance a uniform spacing, x i = a + δ · a , with δ = b a N . The answer is stored in a variable ‘sum’ and displayed. The pseudo-code is then given in algorithm ( 2 ). Algorithm 2 Left point rule 1: Input: f, a, b, N 2: δ b a N 3: sum = 0 4: for i = 0 , . . . , N 1 do 5: x i = a + δ · i 6: sum = sum + f ( x i ) · δ 7: end for 8: Output: sum 2.1 Data Types IMPLICIT NONE IMPLICIT NONE ALWAYS USE THIS ! It makes the use of undeclared variables illegals, leading to compiler errors (In fortran, any undeclared variables is of the type single precision ). INTEGER INTEGER : : i ! exact whole number REAL REAL (4) : : x ! Floating point r e a l numbers , ! t h i s i s by d e f a u l t 6 s i g n i f i c a n t
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

Lecture_notes_summary2 - Chapter 2 Program Elements We seek...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online