Tema22 - 22.11 Option Explicit Sub RhombTest() Dim maxit As...

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
22.11 Option Explicit Sub RhombTest() Dim maxit As Integer Dim a As Single, b As Single, es As Single a = 0 b = 0.8 maxit = 3 es = 0.001 MsgBox Rhomberg(a, b, maxit, es) End Sub Function Rhomberg(a, b, maxit, es) Dim n As Integer, j As Integer, k As Integer, iter As Integer Dim i(10, 10) As Single, ea As Single n = 1 i(1, 1) = TrapEq(n, a, b) iter = 0 Do iter = iter + 1 n = 2 ^ iter i(iter + 1, 1) = TrapEq(n, a, b) For k = 2 To iter + 1 j = 2 + iter - k i(j, k) = (4 ^ (k - 1) * i(j + 1, k - 1) - i(j, k - 1)) / (4 ^ (k - 1) - 1) Next k ea = Abs((i(1, iter + 1) - i(1, iter)) / i(1, iter + 1)) * 100 If (iter >= maxit Or ea <= es) Then Exit Do Loop Rhomberg = i(1, iter + 1) End Function Function TrapEq(n, a, b) Dim i As Integer Dim h As Single, x As Single, sum As Single h = (b - a) / n x = a sum = f(x) For i = 1 To n - 1 x = x + h sum = sum + 2 * f(x) Next i sum = sum + f(b)
Background image of page 6
TrapEq = (b - a) * sum / (2 * n) End Function Function f(x) f = 0.2 + 25 * x - 200 * x ^ 2 + 675 * x ^ 3 - 900 * x ^ 4 + 400 * x ^ 5
Background image of page 7

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

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

Page1 / 8

Tema22 - 22.11 Option Explicit Sub RhombTest() Dim maxit As...

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

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