From 3d270fc24546158e3b7b83ad628c852896fdf867 Mon Sep 17 00:00:00 2001 From: fredrikr79 Date: Sun, 12 Oct 2025 19:19:24 +0200 Subject: [PATCH] ex8: abort --- exercise8/main.typ | 7 ++-- exercise8/problem1.typ | 3 +- exercise8/problem2.typ | 82 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 exercise8/problem2.typ diff --git a/exercise8/main.typ b/exercise8/main.typ index 8d9e0bb..4afdba0 100644 --- a/exercise8/main.typ +++ b/exercise8/main.typ @@ -17,6 +17,10 @@ rect(inset: FONT_SIZE / 2)[#it] } +#show ref: it => if it.element.func() != heading { it } else { + link(it.target, it.element.body) +} + these are my solutions to the eighth exercise set of TMA4135. this document was created using @@ -30,7 +34,6 @@ this document was created using #pagebreak() -= problem 1 - #include "problem1.typ" +#include "problem2.typ" diff --git a/exercise8/problem1.typ b/exercise8/problem1.typ index 3f6bfb0..1f6644e 100644 --- a/exercise8/problem1.typ +++ b/exercise8/problem1.typ @@ -1,6 +1,7 @@ #import "lib.typ": butcher -#import "@preview/physica:0.9.6": * += problem 1 + == a) diff --git a/exercise8/problem2.typ b/exercise8/problem2.typ new file mode 100644 index 0000000..7430763 --- /dev/null +++ b/exercise8/problem2.typ @@ -0,0 +1,82 @@ +#import "lib.typ": butcher + += problem 2 + +== a) + +we can read the coefficients from the calculations of the next $y$-value and +from the stage derivatives $k_i$. additionally, we can tell that there are four +stages, thus it is a fourth order runge-kutta method. + +#butcher(4, ( + $1 slash 2$, + $1 slash 2$, + $3 slash 4$, + 0, + $3 slash 4$, + 1, + $2 slash 9$, + $3 slash 9$, + $4 slash 9$, + $7 slash 24$, + $1 slash 4$, + $1 slash 3$, + $1 slash 8$, +)) + + +== b) + +reading the loop-conditions we can tell that the loop terminates when the next +computed value would overstep the bound $T$ which is set to $2.0$. we increment +the time $t$ by the time step $h = 0.25$ each iteration, such that our values +for $t$ are as follows (upon entry of the loop) +$ + 0.0 -> 0.25 -> 0.5 -> 0.75 -> 1.0 -> 1.25 -> 1.5 -> 1.75. +$ +the next step would yield $t = 2.0$, which is not strictly less than $T$, thus +we terminate the loop. counting the iteration steps, we get that we compute +8 different time steps. + + +== c) + +we have already established that the order is 4. this can also be seen since the +pivot elements of the tableau are non-zero. + +== d) +<2d> + +noticing that the upper part of this butcher tableau is the same as for +ralston's method, and we are working on the same initial value problem, we can +re-use $k_1, k_2$ and $k_3$ from problem @p1. + +thus we only need to compute +$ + k_4 & = f(t_0 + h, y_0 + h(2 k_1 + 3 k_2 + 4 k_3)/9) \ + & = 0.48 dot e^(-0.48 dot (2 dot 0 + 3 dot 0.24 + 4 dot 0.3302)/9) \ + & = #{ 0.48 * calc.exp(-0.48 * (2 * 0 + 3 * 0.24 + 4 * 0.3302) / 9) } +$ + +then assemble into +$ + y_1 & = h (7/24 k_1 + 1/4 k_2 + 1/3 k_3 + 1/8 k_4) \ + & = #{ 0.48 * (7 / 24 * 0 + 1 / 4 * 0.24 + 1 / 3 * 0.3302 + 1 / 8 * 0.4305) } +$ +which is fortunately very reminiscent of what we obtained in @p1. + + +== e) + +we can plug our calculated values for $y_1$ from @2d and @p1 into the +formula +$ + hat(epsilon)_(n+1) + = abs(y_(n+1) - y^*_(n+1)) + = h abs(sum_(i=1)^s (b_i - b^*_i) k_i) +$ +such that +$ + hat(epsilon)_1 = abs(y_1 - y^*_1) + = +$