-
Notifications
You must be signed in to change notification settings - Fork 3
/
line.typ
39 lines (31 loc) · 1.14 KB
/
line.typ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#import "@preview/cetz:0.3.1": canvas, draw
#import "@preview/cetz-plot:0.1.0": plot
#set page(width: auto, height: auto, margin: .5cm)
#let style = (stroke: black, fill: rgb(0, 0, 200, 75))
#let f1(x) = calc.sin(x)
#let fn = (
($ x - x^3"/"3! $, x => x - calc.pow(x, 3)/6),
($ x - x^3"/"3! - x^5"/"5! $, x => x - calc.pow(x, 3)/6 + calc.pow(x, 5)/120),
($ x - x^3"/"3! - x^5"/"5! - x^7"/"7! $, x => x - calc.pow(x, 3)/6 + calc.pow(x, 5)/120 - calc.pow(x, 7)/5040),
)
#set text(size: 10pt)
#canvas({
import draw: *
// Set-up a thin axis style
set-style(axes: (stroke: .5pt, tick: (stroke: .5pt)),
legend: (stroke: none, orientation: ttb, item: (spacing: .3), scale: 80%))
plot.plot(size: (12, 8),
x-tick-step: calc.pi/2,
x-format: plot.formats.multiple-of,
y-tick-step: 2, y-min: -2.5, y-max: 2.5,
legend: "inner-north",
{
let domain = (-1.1 * calc.pi, +1.1 * calc.pi)
for ((title, f)) in fn {
plot.add-fill-between(f, f1, domain: domain,
style: (stroke: none), label: title)
}
plot.add(f1, domain: domain, label: $ sin x $,
style: (stroke: black))
})
})