ex11: init
This commit is contained in:
74
exercise11/lib.typ
Normal file
74
exercise11/lib.typ
Normal file
@@ -0,0 +1,74 @@
|
||||
#let title(cont, size: 18pt) = align(center)[
|
||||
#text(size: size * 2, weight: "bold")[#underline[#cont]]
|
||||
]
|
||||
|
||||
// writes a butcher tableau using the minimum required amount of numbers.
|
||||
#let butcher(s, nums) = {
|
||||
let nums = nums.map(x => if type(x) == float or type(x) == int {
|
||||
$#x$
|
||||
} else { x })
|
||||
table(
|
||||
stroke: (x, y) => if x == 0 and y == s {
|
||||
(right: 0.7pt + black, top: 0.7pt + black)
|
||||
} else if x == 0 {
|
||||
(right: 0.7pt + black)
|
||||
} else if y == s {
|
||||
(top: 0.7pt + black)
|
||||
},
|
||||
align: (x, y) => (
|
||||
if x > 0 { center } else { left }
|
||||
),
|
||||
columns: s + 1,
|
||||
$0$, ..range(s).map(x => none), // first row
|
||||
..range(2, s + 1)
|
||||
.map(i => {
|
||||
let p(i) = calc.floor(i * i / 2 + i / 2 - 1)
|
||||
(
|
||||
nums.slice(p(i - 1), p(i - 1) + i),
|
||||
range(i, s + 1).map(x => none),
|
||||
).flatten()
|
||||
})
|
||||
.flatten(),
|
||||
none, ..nums.rev().slice(0, s).rev() // last row
|
||||
)
|
||||
}
|
||||
|
||||
// automatically adds aligned "if" and "otherwise" strings to a case block.
|
||||
//
|
||||
// example:
|
||||
// ```
|
||||
// $ccases(x, x > 0, -x, x <= 0)$
|
||||
// // is the same as
|
||||
// $cases(x & quad "if" space x > 0, -x & quad "if" space x <= 0$
|
||||
//
|
||||
// $ccases(x, x > 0, -x)$
|
||||
// // is the same as
|
||||
// $cases(x & quad "if" space x > 0, -x & quad "otherwise"$
|
||||
// ```
|
||||
#let ccases(..args) = {
|
||||
let parsed = args.pos().map(x => if type(x) == content { x } else { $#x$ })
|
||||
let result_array = parsed
|
||||
.windows(2)
|
||||
.enumerate()
|
||||
.filter(x => calc.rem-euclid(x.first(), 2) == 0)
|
||||
.map(array.last)
|
||||
.map(x => x.intersperse($& quad "if" space$).join())
|
||||
if calc.rem-euclid(parsed.len(), 2) != 0 {
|
||||
result_array.push($#parsed.last() & quad "otherwise"$)
|
||||
}
|
||||
math.cases(..result_array)
|
||||
};
|
||||
|
||||
// write fourier series faster
|
||||
#let fourier(
|
||||
x: $x$,
|
||||
N: $oo$,
|
||||
a_0: $a_0$,
|
||||
a_n: $a_n$,
|
||||
b_n: $b_n$,
|
||||
) = {
|
||||
$
|
||||
#a_0/2 + sum_(n=1)^#N #a_n cos(n #x)
|
||||
+ sum_(n=1)^#N #b_n sin(n #x)
|
||||
$
|
||||
}
|
||||
38
exercise11/main.typ
Normal file
38
exercise11/main.typ
Normal file
@@ -0,0 +1,38 @@
|
||||
#import "lib.typ"
|
||||
|
||||
#let FONT_SIZE = 18pt;
|
||||
|
||||
#set page(paper: "a4", margin: (x: 2.6cm, y: 2.8cm), numbering: "1 : 1")
|
||||
#set par(justify: true, leading: 0.52em)
|
||||
|
||||
#set text(font: "FreeSerif", size: FONT_SIZE, lang: "us")
|
||||
#show math.equation: set text(
|
||||
font: "Euler Math",
|
||||
size: (FONT_SIZE * 1.0),
|
||||
lang: "en",
|
||||
)
|
||||
|
||||
#set heading(numbering: none)
|
||||
#show heading.where(level: 1): it => {
|
||||
rect(inset: FONT_SIZE / 2)[#it]
|
||||
}
|
||||
|
||||
#show ref: it => if it.element.func() != heading { it } else {
|
||||
link(it.target, it.element.body)
|
||||
}
|
||||
|
||||
#lib.title(size: FONT_SIZE)[exercise 11]
|
||||
|
||||
these are my solutions to the eleventh exercise set of TMA4135.
|
||||
|
||||
this document was created using
|
||||
#link("https://typst.app/")[#text(blue.darken(5%))[typst]].
|
||||
|
||||
\
|
||||
|
||||
#outline(title: none)
|
||||
|
||||
#pagebreak()
|
||||
|
||||
#include "problem1.typ"
|
||||
|
||||
4
exercise11/problem1.typ
Normal file
4
exercise11/problem1.typ
Normal file
@@ -0,0 +1,4 @@
|
||||
#import "@preview/physica:0.9.6": *
|
||||
#import "lib.typ": ccases
|
||||
|
||||
= problem 1
|
||||
BIN
exercise11/problems.pdf
Normal file
BIN
exercise11/problems.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user