-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathtanh.typ
43 lines (39 loc) · 969 Bytes
/
tanh.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
40
41
42
43
#import "@preview/cetz:0.3.2": canvas, draw
#import "@preview/cetz-plot:0.1.1": plot
#set page(width: auto, height: auto, margin: 5pt)
#canvas({
draw.set-style(
axes: (
y: (mark: (end: "stealth", fill: black), label: (anchor: "north-west", offset: -0.2)),
x: (mark: (end: "stealth", fill: black), label: (anchor: "south-east", offset: -0.2)),
),
)
plot.plot(
size: (8, 5),
x-label: $x$,
y-label: $tanh(x)$,
y-max: 1.25,
y-min: -1.25,
x-max: 2,
x-min: -2,
x-tick-step: 1,
y-tick-step: 0.5,
axis-style: "school-book",
{
// Main tanh curve
plot.add(
style: (stroke: blue + 1.5pt),
domain: (-2, 2),
samples: 100,
x => calc.tanh(x),
)
// Dashed line y=x from -1 to 1
plot.add(
style: (stroke: (dash: "dashed", paint: blue, thickness: 0.5pt)),
samples: 2,
domain: (-1.4, 1.4),
x => x,
)
},
)
})