Professional Documents
Culture Documents
Tutorial 4/5 - Lecture Notes: Arrays
Tutorial 4/5 - Lecture Notes: Arrays
Tutorial 4/5 - Lecture Notes: Arrays
column index
Arrays
column 1
column 2
column 3
column 4
𝑏11 𝑏12 𝑏13 𝑏14 row 1 row index
What is the value of the array element with the highest row-index and the
highest column-index?
i_max = ubound(b,1)
j_max = ubound(b,2)
x = b(i_max,j_max)
or
x = b(ubound(b,1), ubound(b,2))
Sum
sum = a + b + c + d
sum = 0
sum = sum + m(1,1)
sum = sum + m(2,1)
sum = sum + m(3,1)
sum = sum + m(4,1)
sum = 0
FOR i = 1 TO 4
sum = sum + m(i,1)
NEXT i
Numerical Integration
Detailed explanation and equations are on the tutorial sheet. Here the focus is on
the concept.
f
𝑏
f(x)
𝑓 𝑥 𝑑𝑥
𝑎
a b x
Simple approximation:
𝑏
𝑓 𝑎 +𝑓 𝑏
≈ 𝑓 𝑥 𝑑𝑥 = 𝑏−𝑎
𝑎 2
f
f(x)
f(b)
f(a)
a b x
Improve accuracy:
f
f(x)
f(b)
f(a)
a b x
Simple approximation:
𝑏
𝑓 𝑎 +𝑓 𝑏
≈ 𝑓 𝑥 𝑑𝑥 = 𝑏−𝑎
𝑎 2
f
f(x)
f(b)
f(a)
a b x
Improve accuracy:
f
f(x)
f(b)
If we have only data points,
f(x) is unknown. In this case
numerical integration is the
only option (apart from
fitting a function g(x) and
integrating that analytically.
f(a)
a b x