Skip to content

Commit

Permalink
add convex-hull-of-stability.typ, skip-connection.typ, sabatier-princ…
Browse files Browse the repository at this point in the history
…iple.typ, branch-cuts-1.typ, change-of-variables.typ and branch-and-bound.typ converted from their LaTeX sources
  • Loading branch information
janosh committed Jan 22, 2025
1 parent 874305b commit 102015b
Show file tree
Hide file tree
Showing 8 changed files with 658 additions and 28 deletions.
60 changes: 60 additions & 0 deletions assets/branch-and-bound/branch-and-bound.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#import "@preview/cetz:0.3.1": canvas, draw

#set page(width: auto, height: auto, margin: 8pt)

#canvas({
import draw: line, content, circle

let node-sep = 1.5 // Horizontal separation between nodes
let level-sep = 1.5 // Vertical separation between levels
let node-radius = 0.35
let arrow-style = (mark: (end: "stealth", fill: black, scale: 0.2), stroke: black + 1pt)

// Helper to draw a node with label
let draw-node(pos, label, name: none) = {
circle(pos, radius: node-radius, name: name)
content(pos, $#label$)
}

// Helper to draw edge label
let draw-edge-label(from, to, label, left: true) = {
let anchor = if left { "east" } else { "west" }
content(
(rel: (if left { -0.3 } else { 0.3 }, 0), to: from + "-" + to + ".mid"),
$#label$,
anchor: anchor,
)
}

// Draw nodes level by level
// Root (level 0)
draw-node((0, 0), $P_0$, name: "p0")

// Level 1
draw-node((-node-sep, -level-sep), $P_1$, name: "p1")
draw-node((node-sep, -level-sep), $P_2$, name: "p2")

// Level 2
draw-node((0, -2 * level-sep), $P_3$, name: "p3")
draw-node((2 * node-sep, -2 * level-sep), $P_4$, name: "p4")

// Level 3
draw-node((-node-sep, -3 * level-sep), $P_5$, name: "p5")
draw-node((node-sep, -3 * level-sep), $P_6$, name: "p6")

// Draw edges
line("p0", "p1", ..arrow-style, name: "p0-p1")
line("p0", "p2", ..arrow-style, name: "p0-p2")
line("p2", "p3", ..arrow-style, name: "p2-p3")
line("p2", "p4", ..arrow-style, name: "p2-p4")
line("p3", "p5", ..arrow-style, name: "p3-p5")
line("p3", "p6", ..arrow-style, name: "p3-p6")

// Draw edge labels
draw-edge-label("p0", "p1", $x_1 <= 0$)
draw-edge-label("p0", "p2", $x_1 >= 1$, left: false)
draw-edge-label("p2", "p3", $x_2 <= 0$)
draw-edge-label("p2", "p4", $x_2 >= 1$, left: false)
draw-edge-label("p3", "p5", $x_3 <= 0$)
draw-edge-label("p3", "p6", $x_3 >= 1$, left: false)
})
84 changes: 84 additions & 0 deletions assets/branch-cuts-1/branch-cuts-1.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#import "@preview/cetz:0.3.1": canvas, draw, decorations


#set page(width: auto, height: auto, margin: 5pt)

#canvas({
import draw: line, content, circle

let xr = 5
let yr = 1
let arrow-style = (mark: (end: "stealth", fill: black, scale: 0.5))

// Draw axes
line(
(0, -yr),
(0, yr),
..arrow-style,
name: "y-axis",
)
content(
(rel: (-0.7, -0.2), to: "y-axis.end"),
$"Im"(p_0)$,
name: "y-label",
)

// Draw branch points
let left-point = (-xr / 2, 0)
let right-point = (xr / 2, 0)

// Draw branch cut line
line(
left-point,
right-point,
name: "x-axis",
mark: (start: "circle", end: "circle", fill: blue, scale: 0.5),
)
// Add branch point labels
content(
(rel: (0, 0.2), to: "x-axis.start"),
$-sqrt(arrow(p)^2)$,
name: "left-label",
)
content(
(rel: (0, 0.2), to: "x-axis.end"),
$sqrt(arrow(p)^2)$,
name: "right-label",
)

// Draw zigzag lines with decorations
let zigzag-style = (
stroke: blue.darken(20%),
amplitude: 0.2,
segment-length: 0.3,
)

// Left zigzag
decorations.zigzag(
line(
(-xr - 0.5, 0),
"x-axis.3%",
..arrow-style,
),
..zigzag-style,
name: "left-zigzag",
)

// Right zigzag
decorations.zigzag(
line(
"x-axis.end",
(xr, 0),
..arrow-style,
),
..zigzag-style,
name: "right-zigzag",
)

// Add Re axis label
content(
(rel: (-0.2, 0.3), to: "right-zigzag.end"),
$"Re"(p_0)$,
name: "x-label",
)
})
118 changes: 118 additions & 0 deletions assets/change-of-variables/change-of-variables.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#import "@preview/cetz:0.3.1": canvas, draw

#set page(width: auto, height: auto, margin: 8pt)

#canvas({
import draw: line, content, rect

let arrow-style = (mark: (end: "stealth", fill: black, scale: 0.5))
let plot-size = 6
let plot-sep = 8

// Helper to draw coordinate axes
let draw-axes(origin, label) = {
// Draw axes
line(
(origin.at(0) - plot-size / 2, origin.at(1)),
(origin.at(0) + plot-size / 2, origin.at(1)),
..arrow-style,
name: label + "-x",
)
line(
(origin.at(0), origin.at(1) - plot-size / 2),
(origin.at(0), origin.at(1) + plot-size / 2),
..arrow-style,
name: label + "-y",
)

// Add axis labels
content((rel: (0, -0.3), to: label + "-x.end"), eval(lower(label) + "_1", mode: "math"), name: label + "-x-label")
content((rel: (0.3, 0), to: label + "-y.end"), eval(lower(label) + "_2", mode: "math"), name: label + "-y-label")

// Add plot label
content(
(origin.at(0) - plot-size / 2, origin.at(1) + plot-size / 2),
text(size: 1.2em)[$#label$],
anchor: "south-west",
name: label + "-title",
)
}

// Draw left plot (Z space)
let z-origin = (0, 0)
draw-axes(z-origin, "Z")

// Draw blue square in Z space
rect(
(z-origin.at(0), z-origin.at(1)),
(z-origin.at(0) + 1, z-origin.at(1) + 1),
fill: blue.transparentize(60%),
name: "z-square",
)

// Draw right plot (X space)
let x-origin = (plot-sep, 0)
draw-axes(x-origin, "X")

// Draw transformed squares in X space
rect(
(x-origin.at(0), x-origin.at(1)),
(x-origin.at(0) + 2, x-origin.at(1) + 2),
fill: red.transparentize(60%),
name: "x-square-1",
)
rect(
(x-origin.at(0), x-origin.at(1)),
(x-origin.at(0) + 2, x-origin.at(1) - 2),
fill: green.transparentize(60%),
name: "x-square-2",
)

// Draw mapping arrows
let mid-x = plot-sep / 2
line(
(mid-x - 0.3, 2.7),
(mid-x + 0.3, 2.7),
..arrow-style,
name: "f-arrow",
)
content("f-arrow.mid", $f$, name: "f-label", anchor: "south", padding: (bottom: 4pt))
line(
(mid-x + 0.3, -2.5),
(mid-x - 0.3, -2.5),
..arrow-style,
name: "f-inv-arrow",
)
content("f-inv-arrow.mid", $f^(-1)$, name: "f-inv-label", anchor: "north", padding: (top: 4pt))

// Draw dotted transformation arrows with determinant labels
line(
"z-square.north-east",
"x-square-1.north-east",
..arrow-style,
stroke: (dash: "dotted", paint: red),
name: "det-arrow-1",
)
content(
(rel: (0.2, -0.2), to: "det-arrow-1.mid"),
[#text(red, $det J_f^(-1) = mat(delim: "|", 2, 0; 0, 2)^(-1) = 1 / 4$)],
anchor: "north",
angle: 5deg,
name: "det-label-1",
)

line(
"z-square.north-east",
"x-square-2.south-east",
..arrow-style,
stroke: (dash: "dotted", paint: green),
name: "det-arrow-2",
)
content(
(rel: (0.2, -0.3), to: "det-arrow-2.mid"),
[#text(green, $det J_f^(-1) = mat(delim: "|", 2, 0; 0, -2)^(-1) = -1 / 4$)],
anchor: "north",
angle: -19deg,
name: "det-label-2",
)
})
Loading

0 comments on commit 102015b

Please sign in to comment.