Compare commits
11 Commits
78bb9a3a9b
...
1a486e2d98
Author | SHA1 | Date | |
---|---|---|---|
1a486e2d98 | |||
28dd6c67bb | |||
473e2875fa | |||
7d29de94ea | |||
38bf88d5ea | |||
a6460cf075 | |||
f7082f3c00 | |||
6197bdb220 | |||
6d56a00622 | |||
ede934369b | |||
3b41ea714a |
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"latex-workshop.latex.recipe.default": "latexmk (xelatex)",
|
"latex-workshop.latex.recipe.default": "latexmk (xelatex)",
|
||||||
"tinymist.formatterPrintWidth": 80
|
"tinymist.formatterPrintWidth": 80,
|
||||||
|
"tinymist.typstExtraArgs": ["--package-path=./lib/typst"]
|
||||||
}
|
}
|
||||||
|
282
lib/typst/local/handout/0.1.0/handout.typ
Executable file
282
lib/typst/local/handout/0.1.0/handout.typ
Executable file
@ -0,0 +1,282 @@
|
|||||||
|
/// Typst handout library, used for all documents in this repository.
|
||||||
|
|
||||||
|
|
||||||
|
/// If false, hide instructor info.
|
||||||
|
///
|
||||||
|
/// Compile with the following command to hide solutions:
|
||||||
|
/// `typst compile main.typ --input show_solutions=false`
|
||||||
|
///
|
||||||
|
/// Solutions are shown by default. This behavior
|
||||||
|
/// is less surprising than hiding content by default.
|
||||||
|
#let show_solutions = {
|
||||||
|
if "show_solutions" in sys.inputs {
|
||||||
|
// Show solutions unless they're explicitly disabled
|
||||||
|
not (
|
||||||
|
sys.inputs.show_solutions == "false" or sys.inputs.show_solutions == "no"
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
// Show solutions by default
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Colors
|
||||||
|
#let ored = rgb("D62121")
|
||||||
|
#let ogrape = rgb("9C36B5")
|
||||||
|
#let ocyan = rgb("2288BF")
|
||||||
|
#let oteal = rgb("12B886")
|
||||||
|
#let ogreen = rgb("37B26D")
|
||||||
|
#let oblue = rgb("1C7ED6")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// MARK: header
|
||||||
|
//
|
||||||
|
|
||||||
|
#let make_title(
|
||||||
|
group,
|
||||||
|
quarter,
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
) = {
|
||||||
|
align(
|
||||||
|
center,
|
||||||
|
block(
|
||||||
|
width: 60%,
|
||||||
|
height: auto,
|
||||||
|
breakable: false,
|
||||||
|
align(
|
||||||
|
center,
|
||||||
|
stack(
|
||||||
|
spacing: 7pt,
|
||||||
|
(
|
||||||
|
text(size: 10pt, group) + h(1fr) + text(size: 10pt, quarter)
|
||||||
|
),
|
||||||
|
line(length: 100%, stroke: 0.2mm),
|
||||||
|
(
|
||||||
|
text(size: 20pt, title) + linebreak() + text(size: 10pt, subtitle)
|
||||||
|
),
|
||||||
|
line(length: 100%, stroke: 0.2mm),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let warn = {
|
||||||
|
set text(ored)
|
||||||
|
align(
|
||||||
|
center,
|
||||||
|
block(
|
||||||
|
width: 60%,
|
||||||
|
height: auto,
|
||||||
|
breakable: false,
|
||||||
|
fill: rgb(255, 255, 255),
|
||||||
|
stroke: ored + 2pt,
|
||||||
|
inset: 3mm,
|
||||||
|
(
|
||||||
|
align(center, text(weight: "bold", size: 12pt, [Instructor's Handout]))
|
||||||
|
+ parbreak()
|
||||||
|
+ align(
|
||||||
|
left,
|
||||||
|
text(
|
||||||
|
size: 10pt,
|
||||||
|
[This handout contains solutions and notes.]
|
||||||
|
+ linebreak()
|
||||||
|
+ [Recompile without solutions before distributing.],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let preparedby(name) = (
|
||||||
|
text(
|
||||||
|
size: 10pt,
|
||||||
|
[Prepared by ]
|
||||||
|
+ name
|
||||||
|
+ [ on ]
|
||||||
|
+ datetime
|
||||||
|
.today()
|
||||||
|
.display("[month repr:long] [day padding:none], [year]"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
//
|
||||||
|
// MARK: Solutions
|
||||||
|
//
|
||||||
|
|
||||||
|
#let solution(content) = {
|
||||||
|
if show_solutions {
|
||||||
|
align(
|
||||||
|
center,
|
||||||
|
stack(
|
||||||
|
block(
|
||||||
|
width: 100%,
|
||||||
|
breakable: false,
|
||||||
|
fill: ored,
|
||||||
|
stroke: ored + 2pt,
|
||||||
|
inset: 1.5mm,
|
||||||
|
(
|
||||||
|
align(left, text(fill: white, weight: "bold", [Solution:]))
|
||||||
|
),
|
||||||
|
),
|
||||||
|
block(
|
||||||
|
width: 100%,
|
||||||
|
height: auto,
|
||||||
|
breakable: false,
|
||||||
|
fill: ored.lighten(80%).desaturate(10%),
|
||||||
|
stroke: ored + 2pt,
|
||||||
|
inset: 3mm,
|
||||||
|
align(left, content),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#let notsolution(content) = {
|
||||||
|
if not show_solutions { content }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// MARK: Sections
|
||||||
|
//
|
||||||
|
|
||||||
|
#let generic(t) = block(
|
||||||
|
above: 8mm,
|
||||||
|
below: 2mm,
|
||||||
|
text(weight: "bold", t),
|
||||||
|
)
|
||||||
|
|
||||||
|
#let _generic_base(kind, ..args) = {
|
||||||
|
counter("obj").step()
|
||||||
|
if args.pos().len() == 0 {
|
||||||
|
generic([
|
||||||
|
#kind
|
||||||
|
#context counter("obj").display():
|
||||||
|
])
|
||||||
|
} else {
|
||||||
|
generic(
|
||||||
|
[
|
||||||
|
#kind
|
||||||
|
#context counter("obj").display():
|
||||||
|
]
|
||||||
|
+ " "
|
||||||
|
+ args.pos().at(0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#let problem(..args) = _generic_base("Problem", ..args)
|
||||||
|
#let definition(..args) = _generic_base("Definition", ..args)
|
||||||
|
#let theorem(..args) = _generic_base("Theorem", ..args)
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// MARK: Misc
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#let hint(content) = {
|
||||||
|
text(fill: rgb(100, 100, 100), style: "oblique", "Hint: ")
|
||||||
|
text(fill: rgb(100, 100, 100), content)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let note(content) = {
|
||||||
|
text(fill: rgb(100, 100, 100), content)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let examplesolution(content) = {
|
||||||
|
let c = oblue
|
||||||
|
|
||||||
|
align(
|
||||||
|
center,
|
||||||
|
stack(
|
||||||
|
block(
|
||||||
|
width: 100%,
|
||||||
|
breakable: false,
|
||||||
|
fill: c,
|
||||||
|
stroke: c + 2pt,
|
||||||
|
inset: 1.5mm,
|
||||||
|
(
|
||||||
|
align(left, text(fill: white, weight: "bold", [Example solution:]))
|
||||||
|
),
|
||||||
|
),
|
||||||
|
block(
|
||||||
|
width: 100%,
|
||||||
|
height: auto,
|
||||||
|
breakable: false,
|
||||||
|
fill: c.lighten(80%).desaturate(10%),
|
||||||
|
stroke: c + 2pt,
|
||||||
|
inset: 3mm,
|
||||||
|
align(left, content),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// MARK: wrapper
|
||||||
|
//
|
||||||
|
|
||||||
|
#let handout(
|
||||||
|
doc,
|
||||||
|
group: none,
|
||||||
|
quarter: none,
|
||||||
|
title: none,
|
||||||
|
by: none,
|
||||||
|
subtitle: none,
|
||||||
|
) = {
|
||||||
|
set par(leading: 0.55em, first-line-indent: 0mm, justify: true)
|
||||||
|
set text(font: "New Computer Modern")
|
||||||
|
set par(spacing: 0.5em)
|
||||||
|
show list: set block(spacing: 0.5em, below: 1em)
|
||||||
|
set heading(numbering: (..nums) => nums.pos().at(0))
|
||||||
|
|
||||||
|
set page(
|
||||||
|
margin: 20mm,
|
||||||
|
width: 8in,
|
||||||
|
height: 11.5in,
|
||||||
|
footer: align(
|
||||||
|
center,
|
||||||
|
context counter(page).display(),
|
||||||
|
),
|
||||||
|
footer-descent: 5mm,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set list(
|
||||||
|
tight: false,
|
||||||
|
indent: 5mm,
|
||||||
|
spacing: 3mm,
|
||||||
|
)
|
||||||
|
|
||||||
|
show heading.where(level: 1): it => {
|
||||||
|
set align(center)
|
||||||
|
set text(weight: "bold")
|
||||||
|
block[
|
||||||
|
Section #counter(heading).display(): #text(it.body)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
make_title(
|
||||||
|
group,
|
||||||
|
quarter,
|
||||||
|
title,
|
||||||
|
{
|
||||||
|
if by == none { none } else { [#preparedby(by)\ ] }
|
||||||
|
if subtitle == none { none } else { subtitle }
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if show_solutions {
|
||||||
|
warn
|
||||||
|
}
|
||||||
|
doc
|
||||||
|
}
|
||||||
|
|
6
lib/typst/local/handout/0.1.0/typst.toml
Normal file
6
lib/typst/local/handout/0.1.0/typst.toml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "handout"
|
||||||
|
version = "0.1.0"
|
||||||
|
entrypoint = "handout.typ"
|
||||||
|
authors = []
|
||||||
|
license = "GPL"
|
70
src/Advanced/Tropical Polynomials/macros.typ
Normal file
70
src/Advanced/Tropical Polynomials/macros.typ
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
#import "@preview/cetz:0.3.1"
|
||||||
|
|
||||||
|
|
||||||
|
// Shorthand, we'll be using these a lot.
|
||||||
|
#let tp = sym.plus.circle
|
||||||
|
#let tm = sym.times.circle
|
||||||
|
|
||||||
|
#let graphgrid(inner_content) = {
|
||||||
|
align(
|
||||||
|
center,
|
||||||
|
box(
|
||||||
|
inset: 3mm,
|
||||||
|
cetz.canvas({
|
||||||
|
import cetz.draw: *
|
||||||
|
let x = 5.25
|
||||||
|
|
||||||
|
grid(
|
||||||
|
(0, 0), (x, x), step: 0.75,
|
||||||
|
stroke: luma(100) + 0.3mm
|
||||||
|
)
|
||||||
|
|
||||||
|
if (inner_content != none) {
|
||||||
|
inner_content
|
||||||
|
}
|
||||||
|
|
||||||
|
mark((0, x + 0.5), (0, x + 1), symbol: ">", fill: black, scale: 1)
|
||||||
|
mark((x + 0.5, 0), (x + 1, 0), symbol: ">", fill: black, scale: 1)
|
||||||
|
|
||||||
|
line(
|
||||||
|
(0, x + 0.25),
|
||||||
|
(0, 0),
|
||||||
|
(x + 0.25, 0),
|
||||||
|
stroke: 0.75mm + black,
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Adds extra padding to an equation.
|
||||||
|
/// Used as follows:
|
||||||
|
///
|
||||||
|
/// #eqmbox($
|
||||||
|
/// f(x) = -2(x #tp 2)(x #tp 8)
|
||||||
|
/// $)
|
||||||
|
///
|
||||||
|
/// Note that there are newlines between the $ and content,
|
||||||
|
/// this gives us display math (which is what we want when using this macro)
|
||||||
|
#let eqnbox(eqn) = {
|
||||||
|
align(
|
||||||
|
center,
|
||||||
|
box(
|
||||||
|
inset: 3mm,
|
||||||
|
eqn,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#let dotline(a, b) = {
|
||||||
|
cetz.draw.line(
|
||||||
|
a,
|
||||||
|
b,
|
||||||
|
stroke: (
|
||||||
|
dash: "dashed",
|
||||||
|
thickness: 0.5mm,
|
||||||
|
paint: ored,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
22
src/Advanced/Tropical Polynomials/main.typ
Normal file
22
src/Advanced/Tropical Polynomials/main.typ
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
|
||||||
|
#show: doc => handout(
|
||||||
|
doc,
|
||||||
|
group: "Advanced 2",
|
||||||
|
quarter: link(
|
||||||
|
"https://betalupi.com/handouts",
|
||||||
|
"betalupi.com/handouts",
|
||||||
|
),
|
||||||
|
|
||||||
|
title: [Tropical Polynomials],
|
||||||
|
by: "Mark",
|
||||||
|
subtitle: "Based on a handout by Bryant Mathews",
|
||||||
|
)
|
||||||
|
|
||||||
|
#include "parts/00 arithmetic.typ"
|
||||||
|
#pagebreak()
|
||||||
|
|
||||||
|
#include "parts/01 polynomials.typ"
|
||||||
|
#pagebreak()
|
||||||
|
|
||||||
|
#include "parts/02 cubic.typ"
|
7
src/Advanced/Tropical Polynomials/meta.toml
Normal file
7
src/Advanced/Tropical Polynomials/meta.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[metadata]
|
||||||
|
title = "Tropical Polynomials"
|
||||||
|
|
||||||
|
|
||||||
|
[publish]
|
||||||
|
handout = true
|
||||||
|
solutions = true
|
293
src/Advanced/Tropical Polynomials/parts/00 arithmetic.typ
Normal file
293
src/Advanced/Tropical Polynomials/parts/00 arithmetic.typ
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
#import "../macros.typ": *
|
||||||
|
|
||||||
|
= Tropical Arithmetic
|
||||||
|
|
||||||
|
#definition()
|
||||||
|
The _tropical sum_ of two numbers is their minimum:
|
||||||
|
$
|
||||||
|
x #tp y = min(x, y)
|
||||||
|
$
|
||||||
|
|
||||||
|
#definition()
|
||||||
|
The _tropical product_ of two numbers is their sum:
|
||||||
|
$
|
||||||
|
x #tm y = x + y
|
||||||
|
$
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
- Is tropical addition commutative? \
|
||||||
|
#note([i.e, does $x #tp y = y #tp x$?])
|
||||||
|
- Is tropical addition associative? \
|
||||||
|
#note([i.e, does $(x #tp y) #tp z = x #tp (y #tp z)$?])
|
||||||
|
- Is there a tropical additive identity? \
|
||||||
|
#note([i.e, is there an $i$ so that $x #tp i = x$ for all real $x$?])
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
- Is tropical addition commutative?\
|
||||||
|
Yes, $min(min(x,y),z) = min(x,y,z) = min(x,min(y,z))$
|
||||||
|
- Is tropical addition associative? \
|
||||||
|
Yes, $min(x,y) = min(y,x)$
|
||||||
|
- Is there a tropical additive identity? \
|
||||||
|
No. There is no $n$ where $x <= n$ for all real $x$
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Let's expand $#sym.RR$ to include a tropical additive identity.
|
||||||
|
- What would be an appropriate name for this new number?
|
||||||
|
- Give a reasonable definition for...
|
||||||
|
- the tropical sum of this number and a real number $x$
|
||||||
|
- the tropical sum of this number and itself
|
||||||
|
- the tropical product of this number and a real number $x$
|
||||||
|
- the tropical product of this number and itself
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
#sym.infinity makes sense, with
|
||||||
|
$#sym.infinity #tp x = x$; #h(1em)
|
||||||
|
$#sym.infinity #tp #sym.infinity = #sym.infinity$; #h(1em)
|
||||||
|
$#sym.infinity #tm x = #sym.infinity$; #h(1em) and
|
||||||
|
$#sym.infinity #tm #sym.infinity = #sym.infinity$
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Do tropical additive inverses exist? \
|
||||||
|
#note([
|
||||||
|
Is there an inverse $y$ for every $x$ so that $x #tp y = #sym.infinity$?
|
||||||
|
])
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
No. Unless $x = #sym.infinity$, there is no x where $min(x, y) = #sym.infinity$
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Is tropical multiplication associative? \
|
||||||
|
#note([Does $(x #tm y) #tm z = x #tm (y #tm z)$ for all $x,y,z$?])
|
||||||
|
|
||||||
|
#solution([Yes, since (normal) addition is associative])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Is tropical multiplication commutative? \
|
||||||
|
#note([Does $x #tm y = y #tm x$ for all $x, y$?])
|
||||||
|
|
||||||
|
#solution([Yes, since (normal) addition is commutative])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Is there a tropical multiplicative identity? \
|
||||||
|
#note([Is there an $i$ so that $x #tm i = x$ for all $x$?])
|
||||||
|
|
||||||
|
#solution([Yes, it is 0.])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Do tropical multiplicative inverses always exist? \
|
||||||
|
#note([
|
||||||
|
For every $x != #sym.infinity$, does there exist an inverse $y$ so that $x #tm y = i$, \
|
||||||
|
where $i$ is the additive identity?
|
||||||
|
])
|
||||||
|
|
||||||
|
#solution([Yes, it is $-x$. For $x != 0$, $x #tm (-x) = 0$])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Is tropical multiplication distributive over addition? \
|
||||||
|
#note([Does $x #tm (y #tp z) = x #tm y #tp x #tm z$?])
|
||||||
|
|
||||||
|
#solution([Yes, $x + min(y,z) = min(x+y, x+z)$])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Fill the following tropical addition and multiplication tables
|
||||||
|
|
||||||
|
#let col = 10mm
|
||||||
|
|
||||||
|
#notsolution(
|
||||||
|
table(
|
||||||
|
columns: (1fr, 1fr),
|
||||||
|
align: center,
|
||||||
|
stroke: none,
|
||||||
|
table(
|
||||||
|
columns: (col, col, col, col, col, col),
|
||||||
|
align: center,
|
||||||
|
table.header(
|
||||||
|
[$#tp$],
|
||||||
|
[$1$],
|
||||||
|
[$2$],
|
||||||
|
[$3$],
|
||||||
|
[$4$],
|
||||||
|
[$#sym.infinity$],
|
||||||
|
),
|
||||||
|
|
||||||
|
box(inset: 3pt, $1$), [], [], [], [], [],
|
||||||
|
box(inset: 3pt, $2$), [], [], [], [], [],
|
||||||
|
box(inset: 3pt, $3$), [], [], [], [], [],
|
||||||
|
box(inset: 3pt, $4$), [], [], [], [], [],
|
||||||
|
box(inset: 3pt, $#sym.infinity$), [], [], [], [], [],
|
||||||
|
),
|
||||||
|
table(
|
||||||
|
columns: (col, col, col, col, col, col),
|
||||||
|
align: center,
|
||||||
|
table.header(
|
||||||
|
[$#tm$],
|
||||||
|
[$0$],
|
||||||
|
[$1$],
|
||||||
|
[$2$],
|
||||||
|
[$3$],
|
||||||
|
[$4$],
|
||||||
|
),
|
||||||
|
|
||||||
|
box(inset: 3pt, $0$), [], [], [], [], [],
|
||||||
|
box(inset: 3pt, $1$), [], [], [], [], [],
|
||||||
|
box(inset: 3pt, $2$), [], [], [], [], [],
|
||||||
|
box(inset: 3pt, $3$), [], [], [], [], [],
|
||||||
|
box(inset: 3pt, $4$), [], [], [], [], [],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
#solution(
|
||||||
|
table(
|
||||||
|
columns: (1fr, 1fr),
|
||||||
|
align: center,
|
||||||
|
stroke: none,
|
||||||
|
table(
|
||||||
|
columns: (col, col, col, col, col, col),
|
||||||
|
align: center,
|
||||||
|
table.header(
|
||||||
|
[$#tp$],
|
||||||
|
[$1$],
|
||||||
|
[$2$],
|
||||||
|
[$3$],
|
||||||
|
[$4$],
|
||||||
|
[$#sym.infinity$],
|
||||||
|
),
|
||||||
|
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
|
||||||
|
box(inset: 3pt, $4$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
box(inset: 3pt, $4$),
|
||||||
|
box(inset: 3pt, $4$),
|
||||||
|
|
||||||
|
box(inset: 3pt, $#sym.infinity$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
box(inset: 3pt, $4$),
|
||||||
|
box(inset: 3pt, $#sym.infinity$),
|
||||||
|
),
|
||||||
|
table(
|
||||||
|
columns: (col, col, col, col, col, col),
|
||||||
|
align: center,
|
||||||
|
table.header(
|
||||||
|
[$#tm$],
|
||||||
|
[$0$],
|
||||||
|
[$1$],
|
||||||
|
[$2$],
|
||||||
|
[$3$],
|
||||||
|
[$4$],
|
||||||
|
),
|
||||||
|
|
||||||
|
box(inset: 3pt, $0$),
|
||||||
|
box(inset: 3pt, $0$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
box(inset: 3pt, $4$),
|
||||||
|
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $1$),
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
box(inset: 3pt, $4$),
|
||||||
|
box(inset: 3pt, $5$),
|
||||||
|
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $2$),
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
box(inset: 3pt, $4$),
|
||||||
|
box(inset: 3pt, $5$),
|
||||||
|
box(inset: 3pt, $6$),
|
||||||
|
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
box(inset: 3pt, $3$),
|
||||||
|
box(inset: 3pt, $4$),
|
||||||
|
box(inset: 3pt, $5$),
|
||||||
|
box(inset: 3pt, $6$),
|
||||||
|
box(inset: 3pt, $7$),
|
||||||
|
|
||||||
|
box(inset: 3pt, $4$),
|
||||||
|
box(inset: 3pt, $4$),
|
||||||
|
box(inset: 3pt, $5$),
|
||||||
|
box(inset: 3pt, $6$),
|
||||||
|
box(inset: 3pt, $7$),
|
||||||
|
box(inset: 3pt, $8$),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Expand and simplify $f(x) = (x #tp 2)(x #tp 3)$, then evaluate $f(1)$ and $f(4)$ \
|
||||||
|
Adjacent parenthesis imply tropical multiplication
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
$
|
||||||
|
(x #tp 2)(x #tp 3)
|
||||||
|
&= x^2 #tp 2x #tp 3x #tp (2 #tm 3) \
|
||||||
|
&= x^2 #tp (2 #tp 3)x #tp (2 #tm 3) \
|
||||||
|
&= x^2 #tp 2x #tp 5
|
||||||
|
$
|
||||||
|
|
||||||
|
Also, $f(1) = 2$ and $f(4) = 5$.
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
387
src/Advanced/Tropical Polynomials/parts/01 polynomials.typ
Normal file
387
src/Advanced/Tropical Polynomials/parts/01 polynomials.typ
Normal file
@ -0,0 +1,387 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
#import "../macros.typ": *
|
||||||
|
#import "@preview/cetz:0.3.1"
|
||||||
|
|
||||||
|
= Tropical Polynomials
|
||||||
|
|
||||||
|
#definition()
|
||||||
|
A _polynomial_ is an expression formed by adding and multiplying numbers and a variable $x$. \
|
||||||
|
Every polynomial can be written as
|
||||||
|
#align(
|
||||||
|
center,
|
||||||
|
box(
|
||||||
|
inset: 3mm,
|
||||||
|
$
|
||||||
|
c_0 + c_1 x + c_2 x^2 + ... + c_n x^n
|
||||||
|
$,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
for some nonnegative integer $n$ and coefficients $c_0, c_1, ..., c_n$. \
|
||||||
|
The _degree_ of a polynomial is the largest $n$ for which $c_n$ is nonzero.
|
||||||
|
|
||||||
|
#theorem()
|
||||||
|
The _fundamental theorem of algebra_ implies that any non-constant polynomial with real coefficients
|
||||||
|
can be written as a product of polynomials of degree 1 or 2 with real coefficients.
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
For example, the polynomial $-160 - 64x - 2x^2 + 17x^3 + 8x^4 + x^5$ \
|
||||||
|
can be written as $(x^2 + 2x+5)(x-2)(x+4)(x+4)$
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
A similar theorem exists for polynomials with complex coefficients. \
|
||||||
|
These coefficients may be found using the roots of this polynomial. \
|
||||||
|
As it turns out, there are formulas that determine the roots of quadratic, cubic, and quartic #note([(degree 2, 3, and 4)]) polynomials. There are no formulas for the roots of polynomials with larger degrees---in this case, we usually rely on approximate roots found by computers.
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
In this section, we will analyze tropical polynomials:
|
||||||
|
- Is there a fundamental theorem of tropical algebra?
|
||||||
|
- Is there a tropical quadratic formula? How about a cubic formula?
|
||||||
|
- Is it difficult to find the roots of tropical polynomials with large degrees?
|
||||||
|
|
||||||
|
|
||||||
|
#definition()
|
||||||
|
A _tropical_ polynomial is a polynomial that uses tropical addition and multiplication. \
|
||||||
|
In other words, it is an expression of the form
|
||||||
|
#align(
|
||||||
|
center,
|
||||||
|
box(
|
||||||
|
inset: 3mm,
|
||||||
|
$
|
||||||
|
c_0 #tp (c_1 #tm x) #tp (c_2 #tm x^2) #tp ... #tp (c_n #tm x^n)
|
||||||
|
$,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
where all exponents represent repeated tropical multiplication.
|
||||||
|
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Draw a graph of the tropical polynomial $f(x) = x^2 #tp 1x #tp 4$. \
|
||||||
|
#hint([$1x$ is not equal to $x$.])
|
||||||
|
|
||||||
|
#notsolution(graphgrid(none))
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
$f(x) = min(2x , 1+x, 4)$, which looks like:
|
||||||
|
|
||||||
|
#graphgrid({
|
||||||
|
import cetz.draw: *
|
||||||
|
let step = 0.75
|
||||||
|
|
||||||
|
dotline((0, 0), (4 * step, 8 * step))
|
||||||
|
dotline((0, 1 * step), (7 * step, 8 * step))
|
||||||
|
dotline((0, 4 * step), (8 * step, 4 * step))
|
||||||
|
|
||||||
|
line(
|
||||||
|
(0, 0),
|
||||||
|
(1 * step, 2 * step),
|
||||||
|
(3 * step, 4 * step),
|
||||||
|
(7.5 * step, 4 * step),
|
||||||
|
stroke: 1mm + oblue,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Now, factor $f(x) = x^2 #tp 1x #tp 4$ into two polynomials with degree 1. \
|
||||||
|
In other words, find $r$ and $s$ so that
|
||||||
|
#align(
|
||||||
|
center,
|
||||||
|
box(
|
||||||
|
inset: 3mm,
|
||||||
|
$
|
||||||
|
x^2 #tp 1x #tp 4 = (x #tp r)(x #tp s)
|
||||||
|
$,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
we will call $r$ and $s$ the _roots_ of $f$.
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
Because $(x #tp r)(x #tp s) = x^2 #tp (r #tp s)x #tp s r$, we must have $r #tp s = 1$ and $r #tm s = 4$. \
|
||||||
|
In standard notation, we need $min(r, s) = 1$ and $r + s = 4$, so we take $r = 1$ and $s = 3$:
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
$
|
||||||
|
f(x) = x^2 #tp 1x #tp 4 = (x #tp 1)(x #tp 3)
|
||||||
|
$
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
How can we use the graph to determine these roots?
|
||||||
|
|
||||||
|
#solution([The roots are the corners of the graph.])
|
||||||
|
|
||||||
|
#v(0.5fr)
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Graph $f(x) = -2x^2 #tp x #tp 8$. \
|
||||||
|
#hint([Use half scale. 1 box = 2 units.])
|
||||||
|
|
||||||
|
#notsolution(graphgrid(none))
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
#graphgrid({
|
||||||
|
import cetz.draw: *
|
||||||
|
let step = 0.75
|
||||||
|
|
||||||
|
dotline((0, 0), (8 * step, 8 * step))
|
||||||
|
dotline((0.5 * step, 0), (4 * step, 8 * step))
|
||||||
|
dotline((0, 4 * step), (8 * step, 4 * step))
|
||||||
|
|
||||||
|
line(
|
||||||
|
(0.5 * step, 0),
|
||||||
|
(1 * step, 1 * step),
|
||||||
|
(4 * step, 4 * step),
|
||||||
|
(7.5 * step, 4 * step),
|
||||||
|
stroke: 1mm + oblue,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
])
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Find a factorization of $f$ in the form $a(x #tp r)(x#tp s)$.
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
We (tropically) factor out $-2$ to get
|
||||||
|
|
||||||
|
#eqnbox($
|
||||||
|
f(x) = -2(x^2 #tp 2x #tp 10)
|
||||||
|
$)
|
||||||
|
|
||||||
|
|
||||||
|
by the same process as the previous problem, we get
|
||||||
|
#eqnbox($
|
||||||
|
f(x) = -2(x #tp 2)(x #tp 8)
|
||||||
|
$)
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Can you see the roots $r$ and $s$ in the graph? \
|
||||||
|
How are the roots related to the coefficients of $f$? \
|
||||||
|
#hint([look at consecutive coefficients: $0 - (-2) = 2$])
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
The roots are the differences between consecutive coefficients of $f$:
|
||||||
|
- $0-(-2) = 2$
|
||||||
|
- $8 - 0 = 8$
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(0.5fr)
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Find a tropical polynomial that has roots $4$ and $5$ \
|
||||||
|
and always produces $7$ for sufficiently large inputs.
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
We are looking for $f(x) = a x^2 #tp b x #tp c$. \
|
||||||
|
Since $f(#sym.infinity) = 7$, we know that $c = 7$. \
|
||||||
|
Using the pattern from the previous problem, we'll subtract $5$ from $c$ to get $b = 2$, \
|
||||||
|
and $4$ from $b$ to get $a = -2$.
|
||||||
|
|
||||||
|
And so, $f(x) = -2x^2 #tp 2x #tp 7$
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
Subtracting roots in the opposite order does not work.
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Graph $f(x) = 1x^2 #tp 3x #tp 5$.
|
||||||
|
|
||||||
|
#notsolution(graphgrid(none))
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
The graphs of all three terms intersect at the same point:
|
||||||
|
|
||||||
|
#graphgrid({
|
||||||
|
import cetz.draw: *
|
||||||
|
let step = 0.75
|
||||||
|
|
||||||
|
dotline((0, 1 * step), (3.5 * step, 8 * step))
|
||||||
|
dotline((0, 5 * step), (8 * step, 5 * step))
|
||||||
|
dotline((0, 3 * step), (5 * step, 8 * step))
|
||||||
|
|
||||||
|
line(
|
||||||
|
(0, 1 * step),
|
||||||
|
(2 * step, 5 * step),
|
||||||
|
(7.5 * step, 5 * step),
|
||||||
|
stroke: 1mm + oblue,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Find a factorization of $f$ in the form $a(x #tp r)(x#tp s)$.
|
||||||
|
|
||||||
|
#solution(
|
||||||
|
eqnbox($
|
||||||
|
f(x) = 1x^2 #tp 3 x #tp 5 = 1(x #tp 2)^2
|
||||||
|
$),
|
||||||
|
)
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
How is this graph different from the previous two? \
|
||||||
|
How is this polynomial's factorization different from the previous two? \
|
||||||
|
How are the roots of $f$ related to its coefficients?
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
The factorization contains the same term twice. \
|
||||||
|
Also note that the differences between consecutive coefficients of $f$ are both two.
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(0.5fr)
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Graph $f(x) = 2x^2 #tp 4x #tp 4$.
|
||||||
|
|
||||||
|
#notsolution(graphgrid(none))
|
||||||
|
|
||||||
|
#solution(
|
||||||
|
graphgrid({
|
||||||
|
import cetz.draw: *
|
||||||
|
let step = 0.75
|
||||||
|
|
||||||
|
dotline((0, 2 * step), (3 * step, 8 * step))
|
||||||
|
dotline((0, 4 * step), (5 * step, 8 * step))
|
||||||
|
dotline((0, 4 * step), (8 * step, 4 * step))
|
||||||
|
|
||||||
|
line(
|
||||||
|
(0, 2 * step),
|
||||||
|
(1 * step, 4 * step),
|
||||||
|
(7.5 * step, 4 * step),
|
||||||
|
stroke: 1mm + oblue,
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Find a factorization of $f$ in the form $a(x #tp r)(x#tp s)$, or show that one does not exist.
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
We can factor out a 2 to get $f(x) = 2(x^2 #tp 2x #tp 2)$,
|
||||||
|
but $x^2 #tp 2x #tp 2$ does not factor. \
|
||||||
|
There are no $a$ and $b$ with minimum 2 and sum 2.
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Find a polynomial that has the same graph as $f$, but can be factored.
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
$
|
||||||
|
2x^2 #tp 3x #tp 4 = 2(x #tp 1)^2
|
||||||
|
$
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
|
||||||
|
#theorem()
|
||||||
|
The _fundamental thorem of tropical algebra_ states that for every tropical polynomial $f$, \
|
||||||
|
there exists a _unique_ tropical polynomial $accent(f, macron)$ with the same graph that can be factored \
|
||||||
|
into linear factors.
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
Whenever we say "the roots of $f$", we really mean "the roots of $accent(f, macron)$." \
|
||||||
|
$f$ and $accent(f, macron)$ might be the same polynomial.
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
If $f(x) = a x^2 #tp b x #tp c$, then $accent(f, macron)(x) = a x^2 #tp B x #tp c$ for some $B$. \
|
||||||
|
Find a formula for $B$ in terms of $a$, $b$, and $c$. \
|
||||||
|
#hint([there are two cases to consider.])
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
If we want to factor $a(x^2 #tp (b-a)x #tp (c-a))$, we need to find $r$ and $s$ so that
|
||||||
|
- $min(r,s) = b-a$, and
|
||||||
|
- $r + s = c - a$
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
This is possible if and only if $2(b-a) <= c-a$, \
|
||||||
|
or equivalently if $b <= (a+c) #sym.div 2$
|
||||||
|
|
||||||
|
#v(8mm)
|
||||||
|
|
||||||
|
*Case 1:* If $b <= (a + c #sym.div) 2$, then $accent(f, macron) = f$ and $b = B$.
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
*Case 2:* If $b > (a + c #sym.div) 2$, then
|
||||||
|
$
|
||||||
|
accent(f, macron)(x)
|
||||||
|
&= a x^2 #tp ((a+c)/2)x #tp c \
|
||||||
|
&= a(x #tp (c-a)/2)^2
|
||||||
|
$
|
||||||
|
has the same graph as $f$, and thus $B = (a+c) #sym.div 2$
|
||||||
|
|
||||||
|
#v(8mm)
|
||||||
|
|
||||||
|
We can combine these results as follows:
|
||||||
|
$
|
||||||
|
B = min(b, (a+c)/2)
|
||||||
|
$
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Find a tropical quadratic formula in terms of $a$, $b$, and $c$ \
|
||||||
|
for the roots $x$ of a tropical polynomial $f(x) = a x^2 #tp b x #tp c$. \
|
||||||
|
#hint([
|
||||||
|
again, there are two cases. \
|
||||||
|
Remember that "roots of $f$" means "roots of $accent(f, macron)$".
|
||||||
|
])
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
*Case 1:* If $b <= (a+c) #sym.div 2$, then $accent(f, macron) = f$ has roots $b-a$ and $c-b$, so
|
||||||
|
$
|
||||||
|
accent(f, macron)(x) = a(x #tp (b-a))(x #tp (c-b))
|
||||||
|
$
|
||||||
|
|
||||||
|
#v(8mm)
|
||||||
|
|
||||||
|
*Case 2:* If $b > (a+c) #sym.div 2$, then $accent(f, macron)$ has root $(c-a) #sym.div$ with multiplicity 2, so
|
||||||
|
$
|
||||||
|
accent(f, macron)(x) = a(x #tp (c-a)/2)^2
|
||||||
|
$
|
||||||
|
|
||||||
|
#v(8mm)
|
||||||
|
|
||||||
|
It is interesting to note that the condition $2b < a+ c$ for there to be two distinct roots becomes $b^2 > a c$ in tropical notation. This is reminiscent of the discriminant condition for standard polynomials!
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
212
src/Advanced/Tropical Polynomials/parts/02 cubic.typ
Normal file
212
src/Advanced/Tropical Polynomials/parts/02 cubic.typ
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
#import "../macros.typ": *
|
||||||
|
#import "@preview/cetz:0.3.1"
|
||||||
|
|
||||||
|
= Tropical Cubic Polynomials
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Consider the polynomial $f(x) = x^3 #tp x^2 #tp 3x #tp 6$. \
|
||||||
|
- sketch a graph of this polynomial
|
||||||
|
- use this graph to find the roots of $f$
|
||||||
|
- write (and expand) a product of linear factors with the same graph as $f$.
|
||||||
|
|
||||||
|
#notsolution(graphgrid(none))
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
- Roots are 1, 2, and 3.
|
||||||
|
- $accent(f, macron)(x) = x^3 #tp 1x^2 #tp 3x #tp 6 = (x #tp 1)(x #tp 2)(x #tp 3)$
|
||||||
|
|
||||||
|
|
||||||
|
#graphgrid({
|
||||||
|
import cetz.draw: *
|
||||||
|
let step = 0.75
|
||||||
|
|
||||||
|
dotline((0, 0), (2.66 * step, 8 * step))
|
||||||
|
dotline((0, 1 * step), (3.5 * step, 8 * step))
|
||||||
|
dotline((0, 3 * step), (5 * step, 8 * step))
|
||||||
|
dotline((0, 6 * step), (8 * step, 6 * step))
|
||||||
|
|
||||||
|
line(
|
||||||
|
(0, 0),
|
||||||
|
(1 * step, 3 * step),
|
||||||
|
(2 * step, 5 * step),
|
||||||
|
(3 * step, 6 * step),
|
||||||
|
(7.5 * step, 6 * step),
|
||||||
|
stroke: 1mm + oblue,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Consider the polynomial $f(x) = x^3 #tp x^2 #tp 6x #tp 6$. \
|
||||||
|
- sketch a graph of this polynomial
|
||||||
|
- use this graph to find the roots of $f$
|
||||||
|
- write (and expand) a product of linear factors with the same graph as $f$.
|
||||||
|
|
||||||
|
#notsolution(graphgrid(none))
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
- Roots are 1, 2.5, and 2.5.
|
||||||
|
- $accent(f, macron)(x) = x^3 #tp 1x^2 #tp 3.5x #tp 6 = (x #tp 1)(x #tp 2.5)^2$
|
||||||
|
|
||||||
|
#graphgrid({
|
||||||
|
import cetz.draw: *
|
||||||
|
let step = 0.75
|
||||||
|
|
||||||
|
dotline((0, 0), (2.66 * step, 8 * step))
|
||||||
|
dotline((0, 1 * step), (3.5 * step, 8 * step))
|
||||||
|
dotline((0, 6 * step), (2 * step, 8 * step))
|
||||||
|
dotline((0, 6 * step), (8 * step, 6 * step))
|
||||||
|
|
||||||
|
line(
|
||||||
|
(0, 0),
|
||||||
|
(1 * step, 3 * step),
|
||||||
|
(2.5 * step, 6 * step),
|
||||||
|
(7.5 * step, 6 * step),
|
||||||
|
stroke: 1mm + oblue,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Consider the polynomial $f(x) = x^3 #tp 6x^2 #tp 6x #tp 6$. \
|
||||||
|
- sketch a graph of this polynomial
|
||||||
|
- use this graph to find the roots of $f$
|
||||||
|
- write (and expand) a product of linear factors with the same graph as $f$.
|
||||||
|
|
||||||
|
#notsolution(graphgrid(none))
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
- Roots are 2, 2, and 2.
|
||||||
|
- $accent(f, macron)(x) = x^3 #tp 2x^2 #tp 4x #tp 6 = (x #tp 2)^3$
|
||||||
|
|
||||||
|
#graphgrid({
|
||||||
|
import cetz.draw: *
|
||||||
|
let step = 0.75
|
||||||
|
|
||||||
|
dotline((0, 0), (2.66 * step, 8 * step))
|
||||||
|
dotline((0, 6 * step), (1 * step, 8 * step))
|
||||||
|
dotline((0, 6 * step), (2 * step, 8 * step))
|
||||||
|
dotline((0, 6 * step), (8 * step, 6 * step))
|
||||||
|
|
||||||
|
line(
|
||||||
|
(0, 0),
|
||||||
|
(2 * step, 6 * step),
|
||||||
|
(7.5 * step, 6 * step),
|
||||||
|
stroke: 1mm + oblue,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
If $f(x) = a x^3 #tp b x^2 #tp c x #tp d$, then $accent(f, macron)(x) = a x^3 #tp B x^2 #tp C x #tp d$ for some $B$ and $C$. \
|
||||||
|
Using the last three problems, find formulas for $B$ and $C$ in terms of $a$, $b$, $c$, and $d$.
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
|
||||||
|
$
|
||||||
|
B = min(b, (a+c)/2, (2a+d)/2)
|
||||||
|
$
|
||||||
|
$
|
||||||
|
C = min(c, (b+d)/2, (a+2d)/2)
|
||||||
|
$
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
What are the roots of the following polynomial?
|
||||||
|
|
||||||
|
#align(
|
||||||
|
center,
|
||||||
|
box(
|
||||||
|
inset: 3mm,
|
||||||
|
$
|
||||||
|
3 x^6 #tp 4 x^5 #tp 2 x^4 #tp x^3 #tp x^2 #tp 4 x #tp 5
|
||||||
|
$,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
We have
|
||||||
|
$
|
||||||
|
accent(f, macron)(x) = 3x^6 #tp 2x^5 #tp 1x^4 #tp x^3 #tp 1x^2 #tp 3x #tp 5
|
||||||
|
$
|
||||||
|
which has roots $-1$, $-1$, $-1$, $1$, $2$, $2$
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
#pagebreak() // MARK: page
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
If
|
||||||
|
$
|
||||||
|
f(x) = c_0 #tp c_1 x #tp c_2 x^2 #tp ... #tp c_n x^n
|
||||||
|
$
|
||||||
|
then
|
||||||
|
$
|
||||||
|
accent(f, macron)(x) = c_0 #tp C_1 x #tp C_2 x^2 #tp ... #tp C_(n-1) x^(n-1) #tp c_n x^n
|
||||||
|
$
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
Find a formula for each $C_i$ in terms of $c_0, c_1, ..., c_n$.
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
$
|
||||||
|
A_j
|
||||||
|
&= min_(l<=j<k)( (a_l - a_k) / (k-l) (k-j) + a_k ) \
|
||||||
|
&= min_(l<=j<k)( a_l (k-j) / (k-l) + a_k (j-l) / (k-l) )
|
||||||
|
$
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
which is a weighted average of some $a_l$ and $a_k$, with $l<=j<k$
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
With the same setup as the previous problem, \
|
||||||
|
find formulas for the roots $r_1, r_2, ..., r_n$.
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
The roots are the differences between consecutive coefficients of $accent(f, macron)$:
|
||||||
|
$
|
||||||
|
r_i = A_i - A_(i-1)
|
||||||
|
$
|
||||||
|
where we set $A_n = a_n$ and $A_0 = a_0$.
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Can you find a geometric interpretation of these formulas \
|
||||||
|
in terms of the points $(-i, c_i)$ for $0 <= i <= n$?
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
The inequality #note([(for $l <= k < k$)])
|
||||||
|
$
|
||||||
|
A_j <= (a_l - a_k) / (k-l) (k-j)+a_k
|
||||||
|
$
|
||||||
|
states that the point $(-j,A_j)$ must lie on or below the line segment between the points $(-k, a_k)$ and $(-l, a_l)$.
|
||||||
|
This makes it easy to find the $A_j$ using a graph of the points $(-i, a_i)$ for $0 <= i <=n$.
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(0.5fr)
|
@ -1,35 +0,0 @@
|
|||||||
\documentclass[
|
|
||||||
solutions,
|
|
||||||
hidewarning,
|
|
||||||
singlenumbering,
|
|
||||||
nopagenumber
|
|
||||||
]{../../../lib/tex/ormc_handout}
|
|
||||||
\usepackage{../../../lib/tex/macros}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\title{Warm-Up: A Familiar Concept}
|
|
||||||
\uptitler{\smallurl{}}
|
|
||||||
\subtitle{Prepared by Mark on \today}
|
|
||||||
|
|
||||||
|
|
||||||
\begin{document}
|
|
||||||
|
|
||||||
\maketitle
|
|
||||||
|
|
||||||
|
|
||||||
\problem{}<one>
|
|
||||||
Let $v = [-5, -2, 0, 1, 4, 1000]$. Find all $x$ that minimize the following metric. \par
|
|
||||||
$$
|
|
||||||
\sum_{\forall i} |v_i - x| = |v_1 - x| + |v_2 - x| + ... + |v_6 - x|
|
|
||||||
$$
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
Let $v = [-5, -2, 0, 1, 4, 1000, 1001]$. Find all $x$ that minimize the metric in \ref{one}.
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
What is this metric usually called?
|
|
||||||
|
|
||||||
\end{document}
|
|
39
src/Warm-Ups/A Familiar Concept/main.typ
Normal file
39
src/Warm-Ups/A Familiar Concept/main.typ
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
|
||||||
|
#show: doc => handout(
|
||||||
|
doc,
|
||||||
|
quarter: link(
|
||||||
|
"https://betalupi.com/handouts",
|
||||||
|
"betalupi.com/handouts",
|
||||||
|
),
|
||||||
|
|
||||||
|
title: [Warm-Up: A Familiar Concept],
|
||||||
|
by: "Mark",
|
||||||
|
)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Let $v = [-5, -2, 0, 1, 4, 1000]$. Find all $x$ that minimize the following metric:
|
||||||
|
|
||||||
|
#align(
|
||||||
|
center,
|
||||||
|
box(
|
||||||
|
inset: 3mm,
|
||||||
|
$
|
||||||
|
sum_(#sym.forall i) |v_i - x| = |v_1 - x| + |v_2 - x| + ... + |v_6 - x|
|
||||||
|
$,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Let $v = [-5, -2, 0, 1, 4, 1000, 1001]$. Find all $x$ that minimize the metric in the previous problem.
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
What is this metric usually called?
|
||||||
|
|
||||||
|
|
||||||
|
#v(0.25fr)
|
@ -1,31 +0,0 @@
|
|||||||
\documentclass[
|
|
||||||
solutions,
|
|
||||||
hidewarning,
|
|
||||||
singlenumbering,
|
|
||||||
nopagenumber
|
|
||||||
]{../../../lib/tex/ormc_handout}
|
|
||||||
\usepackage{../../../lib/tex/macros}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\title{Warm-Up: Fuse Timers}
|
|
||||||
\uptitler{\smallurl{}}
|
|
||||||
\subtitle{Prepared by Mark on \today.}
|
|
||||||
|
|
||||||
\begin{document}
|
|
||||||
|
|
||||||
\maketitle
|
|
||||||
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
Suppose we have two strings and a lighter. Each string takes an hour to fully burn. \par
|
|
||||||
However, we do not know how fast each part of the string burns:
|
|
||||||
half might burn in 1 minute, and the rest could take 59.
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
How would we measure exactly 45 minutes using these strings?
|
|
||||||
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
\end{document}
|
|
21
src/Warm-Ups/Fuse Timers/main.typ
Normal file
21
src/Warm-Ups/Fuse Timers/main.typ
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
|
||||||
|
#show: doc => handout(
|
||||||
|
doc,
|
||||||
|
quarter: link(
|
||||||
|
"https://betalupi.com/handouts",
|
||||||
|
"betalupi.com/handouts",
|
||||||
|
),
|
||||||
|
|
||||||
|
title: [Warm-Up: Fuse Timers],
|
||||||
|
by: "Mark",
|
||||||
|
)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Suppose we have two strings and a lighter. Each string takes exactly an hour to fully burn. \
|
||||||
|
However, we do not know how fast each part of the string burns:
|
||||||
|
half might burn in 1 minute, and the rest could take 59.
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
How can we measure exactly 45 minutes using these two strings?
|
@ -1,54 +0,0 @@
|
|||||||
\documentclass[
|
|
||||||
solutions,
|
|
||||||
hidewarning,
|
|
||||||
singlenumbering,
|
|
||||||
nopagenumber
|
|
||||||
]{../../../lib/tex/ormc_handout}
|
|
||||||
\usepackage{../../../lib/tex/macros}
|
|
||||||
|
|
||||||
|
|
||||||
\title{Warm-Up: Mario Kart}
|
|
||||||
\uptitler{\smallurl{}}
|
|
||||||
\subtitle{Prepared by Mark on \today}
|
|
||||||
|
|
||||||
|
|
||||||
\begin{document}
|
|
||||||
|
|
||||||
\maketitle
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
A standard Mario Kart cup consists of 12 players and four races. \par
|
|
||||||
Each race is scored as follows:
|
|
||||||
\begin{itemize}
|
|
||||||
\item 15 points are awarded for first place;
|
|
||||||
\item 12 for second;
|
|
||||||
\item and $(13 - \text{place})$ otherwise.
|
|
||||||
\end{itemize}
|
|
||||||
In any one race, no players may tie.
|
|
||||||
A player's score at the end of a cup is the sum of their scores for each of the four races.
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
An $n$-way tie occurs when the top $n$ players have the same score at the end of a round. \par
|
|
||||||
What is the largest possible $n$, and how is it achieved?
|
|
||||||
|
|
||||||
\begin{solution}
|
|
||||||
A 12-way tie is impossible, since the total number of point is not divisible by 12.
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
A 11-way tie is possible, with a top score of 28:
|
|
||||||
\begin{itemize}
|
|
||||||
\item Four players finish $1^\text{st}$, $3^\text{ed}$, $11^\text{th}$, and $12^\text{th}$;
|
|
||||||
|
|
||||||
% spell:off
|
|
||||||
\item Four players finish $2^\text{nd}$, $4^\text{th}$, $9^\text{th}$, and $10^\text{th}$;
|
|
||||||
% spell:on
|
|
||||||
|
|
||||||
\item Two players finish fifth twice and seventh twice,
|
|
||||||
\item One player finishes sixth in each race.
|
|
||||||
\end{itemize}
|
|
||||||
The final player always finishes eighth, with a non-tie score of 20.
|
|
||||||
\end{solution}
|
|
||||||
|
|
||||||
\end{document}
|
|
41
src/Warm-Ups/Mario Kart/main.typ
Normal file
41
src/Warm-Ups/Mario Kart/main.typ
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
|
||||||
|
#show: doc => handout(
|
||||||
|
doc,
|
||||||
|
quarter: link(
|
||||||
|
"https://betalupi.com/handouts",
|
||||||
|
"betalupi.com/handouts",
|
||||||
|
),
|
||||||
|
|
||||||
|
title: [Warm-Up: Mario Kart],
|
||||||
|
by: "Mark",
|
||||||
|
)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
A standard Mario Kart cup consists of 12 players and four races. \
|
||||||
|
Each race is scored as follows:
|
||||||
|
- 15 points are awarded for first place;
|
||||||
|
- 12 for second;
|
||||||
|
- and $(13 - #text("place"))$ otherwise.
|
||||||
|
|
||||||
|
In any one race, no players may tie. \
|
||||||
|
A player's score at the end of a cup is the sum of their scores for each of the four races.
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
An $n$-way tie occurs when the top $n$ players have the same score at the end of a round. \
|
||||||
|
What is the largest possible $n$, and how is it achieved?
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
A 12-way tie is impossible, since the total number of point is not divisible by 12.
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
A 11-way tie is possible, with a top score of 28:
|
||||||
|
- Four players finish $1^#text("st")$, $3^#text("ed")$, $11^#text("th")$, and $12^#text("th")$;
|
||||||
|
- Four players finish $2^#text("nd")$, $4^#text("th")$, $9^#text("th")$, and $10^#text("th")$; // spell:disable-line
|
||||||
|
- Two players finish fifth twice and seventh twice,
|
||||||
|
- One player finishes sixth in each race.
|
||||||
|
The final player always finishes eighth, with a non-tie score of 20.
|
||||||
|
|
||||||
|
])
|
@ -1,132 +0,0 @@
|
|||||||
\documentclass[
|
|
||||||
nosolutions,
|
|
||||||
hidewarning,
|
|
||||||
singlenumbering,
|
|
||||||
nopagenumber
|
|
||||||
]{../../../lib/tex/ormc_handout}
|
|
||||||
\usepackage{../../../lib/tex/macros}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\usepackage{tikz}
|
|
||||||
\usetikzlibrary{arrows.meta}
|
|
||||||
\usetikzlibrary{shapes.geometric}
|
|
||||||
|
|
||||||
% We put nodes in a separate layer, so we can
|
|
||||||
% slightly overlap with paths for a perfect fit
|
|
||||||
\pgfdeclarelayer{nodes}
|
|
||||||
\pgfdeclarelayer{path}
|
|
||||||
\pgfsetlayers{main,nodes}
|
|
||||||
|
|
||||||
% Layer settings
|
|
||||||
\tikzset{
|
|
||||||
% Layer hack, lets us write
|
|
||||||
% later = * in scopes.
|
|
||||||
layer/.style = {
|
|
||||||
execute at begin scope={\pgfonlayer{#1}},
|
|
||||||
execute at end scope={\endpgfonlayer}
|
|
||||||
},
|
|
||||||
%
|
|
||||||
% Arrowhead tweak
|
|
||||||
>={Latex[ width=2mm, length=2mm ]},
|
|
||||||
%
|
|
||||||
% Nodes
|
|
||||||
main/.style = {
|
|
||||||
draw,
|
|
||||||
circle,
|
|
||||||
fill = white,
|
|
||||||
line width = 0.35mm
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
\title{Warm Up: Odd Dice}
|
|
||||||
\uptitler{\smallurl{}}
|
|
||||||
\subtitle{Prepared by Mark on \today}
|
|
||||||
|
|
||||||
|
|
||||||
\begin{document}
|
|
||||||
|
|
||||||
\maketitle
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
|
|
||||||
We say a set of dice $\{A, B, C\}$ is \textit{nontransitive}
|
|
||||||
if, on average, $A$ beats $B$, $B$ beats $C$, and $C$ beats $A$.
|
|
||||||
In other words, we get a counterintuitive \say{rock - paper - scissors} effect.
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
Create a set of nontransitive six-sided dice. \par
|
|
||||||
\hint{All sides should be numbered with positive integers less than 10.}
|
|
||||||
|
|
||||||
\begin{solution}
|
|
||||||
One possible set can be numbered as follows:
|
|
||||||
\begin{itemize}
|
|
||||||
\item Die $A$: $2, 2, 4, 4, 9, 9$
|
|
||||||
\item Die $B$: $1, 1, 6, 6, 8, 8$
|
|
||||||
\item Die $C$: $3, 3, 5, 5, 7, 7$
|
|
||||||
\end{itemize}
|
|
||||||
|
|
||||||
\vspace{4mm}
|
|
||||||
|
|
||||||
Another solution is below:
|
|
||||||
\begin{itemize}
|
|
||||||
\item Die $A$: $3, 3, 3, 3, 3, 6$
|
|
||||||
\item Die $B$: $2, 2, 2, 5, 5, 5$
|
|
||||||
\item Die $C$: $1, 4, 4, 4, 4, 4$
|
|
||||||
\end{itemize}
|
|
||||||
\end{solution}
|
|
||||||
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
Now, consider the set of six-sided dice below:
|
|
||||||
\begin{itemize}
|
|
||||||
\item Die $A$: $4, 4, 4, 4, 4, 9$
|
|
||||||
\item Die $B$: $3, 3, 3, 3, 8, 8$
|
|
||||||
\item Die $C$: $2, 2, 2, 7, 7, 7$
|
|
||||||
\item Die $D$: $1, 1, 6, 6, 6, 6$
|
|
||||||
\item Die $E$: $0, 5, 5, 5, 5, 5$
|
|
||||||
\end{itemize}
|
|
||||||
On average, which die beats each of the others? Draw a graph. \par
|
|
||||||
|
|
||||||
\begin{solution}
|
|
||||||
\begin{center}
|
|
||||||
\begin{tikzpicture}[scale = 0.5]
|
|
||||||
\begin{scope}[layer = nodes]
|
|
||||||
\node[main] (a) at (-2, 0.2) {$a$};
|
|
||||||
\node[main] (b) at (0, 2) {$b$};
|
|
||||||
\node[main] (c) at (2, 0.2) {$c$};
|
|
||||||
\node[main] (d) at (1, -2) {$d$};
|
|
||||||
\node[main] (e) at (-1, -2) {$e$};
|
|
||||||
\end{scope}
|
|
||||||
|
|
||||||
\draw[->]
|
|
||||||
(a) edge (b)
|
|
||||||
(b) edge (c)
|
|
||||||
(c) edge (d)
|
|
||||||
(d) edge (e)
|
|
||||||
(e) edge (a)
|
|
||||||
|
|
||||||
(a) edge (c)
|
|
||||||
(b) edge (d)
|
|
||||||
(c) edge (e)
|
|
||||||
(d) edge (a)
|
|
||||||
(e) edge (b)
|
|
||||||
;
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{center}
|
|
||||||
\end{solution}
|
|
||||||
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
Now, say we roll each die twice. What happens to the graph above?
|
|
||||||
|
|
||||||
\begin{solution}
|
|
||||||
The direction of each edge is reversed!
|
|
||||||
\end{solution}
|
|
||||||
|
|
||||||
\vfill
|
|
||||||
\pagebreak
|
|
||||||
|
|
||||||
\end{document}
|
|
87
src/Warm-Ups/Odd Dice/main.typ
Normal file
87
src/Warm-Ups/Odd Dice/main.typ
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
|
||||||
|
#show: doc => handout(
|
||||||
|
doc,
|
||||||
|
quarter: link(
|
||||||
|
"https://betalupi.com/handouts",
|
||||||
|
"betalupi.com/handouts",
|
||||||
|
),
|
||||||
|
|
||||||
|
title: [Warm-Up: Odd Dice],
|
||||||
|
by: "Mark",
|
||||||
|
)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
We say a set of dice ${A, B, C}$ is _nontransitive_
|
||||||
|
if, on average, $A$ beats $B$, $B$ beats $C$, and $C$ beats $A$.
|
||||||
|
In other words, we get a counterintuitive "rock - paper - scissors" effect.
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
Create a set of nontransitive six-sided dice. \
|
||||||
|
#hint([All sides should be numbered with positive integers less than 10.])
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
One possible set can be numbered as follows:
|
||||||
|
- Die $A$: $2, 2, 4, 4, 9, 9$
|
||||||
|
- Die $B$: $1, 1, 6, 6, 8, 8$
|
||||||
|
- Die $C$: $3, 3, 5, 5, 7, 7$
|
||||||
|
|
||||||
|
#v(4mm)
|
||||||
|
|
||||||
|
Another solution is below:
|
||||||
|
- Die $A$: $3, 3, 3, 3, 3, 6$
|
||||||
|
- Die $B$: $2, 2, 2, 5, 5, 5$
|
||||||
|
- Die $C$: $1, 4, 4, 4, 4, 4$
|
||||||
|
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Now, consider the set of six-sided dice below:
|
||||||
|
- Die $A$: $4, 4, 4, 4, 4, 9$
|
||||||
|
- Die $B$: $3, 3, 3, 3, 8, 8$
|
||||||
|
- Die $C$: $2, 2, 2, 7, 7, 7$
|
||||||
|
- Die $D$: $1, 1, 6, 6, 6, 6$
|
||||||
|
- Die $E$: $0, 5, 5, 5, 5, 5$
|
||||||
|
On average, which die beats each of the others? Draw a diagram.
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
/*
|
||||||
|
\begin{tikzpicture}[scale = 0.5]
|
||||||
|
\begin{scope}[layer = nodes]
|
||||||
|
\node[main] (a) at (-2, 0.2) {$a$};
|
||||||
|
\node[main] (b) at (0, 2) {$b$};
|
||||||
|
\node[main] (c) at (2, 0.2) {$c$};
|
||||||
|
\node[main] (d) at (1, -2) {$d$};
|
||||||
|
\node[main] (e) at (-1, -2) {$e$};
|
||||||
|
\end{scope}
|
||||||
|
|
||||||
|
\draw[->]
|
||||||
|
(a) edge (b)
|
||||||
|
(b) edge (c)
|
||||||
|
(c) edge (d)
|
||||||
|
(d) edge (e)
|
||||||
|
(e) edge (a)
|
||||||
|
|
||||||
|
(a) edge (c)
|
||||||
|
(b) edge (d)
|
||||||
|
(c) edge (e)
|
||||||
|
(d) edge (a)
|
||||||
|
(e) edge (b)
|
||||||
|
;
|
||||||
|
\end{tikzpicture}
|
||||||
|
*/
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Now, say we roll each die twice. What happens to the graph fromE the previous problem?
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
The direction of each edge is reversed!
|
||||||
|
])
|
||||||
|
|
||||||
|
#v(1fr)
|
@ -1,57 +0,0 @@
|
|||||||
\documentclass[
|
|
||||||
solutions,
|
|
||||||
singlenumbering,
|
|
||||||
nopagenumber
|
|
||||||
]{../../../lib/tex/ormc_handout}
|
|
||||||
\usepackage{../../../lib/tex/macros}
|
|
||||||
|
|
||||||
|
|
||||||
\title{Warm-Up: Partition Products}
|
|
||||||
\uptitler{\smallurl{}}
|
|
||||||
\subtitle{Prepared by Mark on \today.}
|
|
||||||
|
|
||||||
\begin{document}
|
|
||||||
|
|
||||||
\maketitle
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
Take any positive integer $n$. \par
|
|
||||||
Now, write it as sum of smaller positive integers: $n = a_1 + a_2 + ... + a_k$ \par
|
|
||||||
Maximize the product $a_1 \times a_2 \times ... \times a_k$
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\begin{solution}
|
|
||||||
|
|
||||||
\textbf{Interesting Solution:}
|
|
||||||
|
|
||||||
Of course, all $a_i$ should be greater than $1$. \par
|
|
||||||
Also, all $a_i$ should be smaller than four, since $x \leq x(x-2)$ if $x \geq 4$. \par
|
|
||||||
Thus, we're left with sequences that only contain 2 and 3. \par
|
|
||||||
\note{Note that two twos are the same as one four, but we exclude fours for simplicity.}
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
Finally, we see that $3^2 > 2^3$, so any three twos are better repackaged as two threes. \par
|
|
||||||
The best sequence $a_i$ thus consists of a maximal number of threes followed by 0, 1, or 2 twos.
|
|
||||||
|
|
||||||
\linehack{}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\textbf{Calculus Solution:}
|
|
||||||
|
|
||||||
First, solve this problem for equal, non-integer $a_i$:
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
We know $n = \prod{a_i}$, thus $\ln(n) = \sum{\ln(a_i)}$. \par
|
|
||||||
If all $a_i$ are equal, we get $\ln(n) = k \times \ln(n / k)$. \par
|
|
||||||
Derive wrt $k$ and set to zero to get $\ln(n / k) = 1$ \par
|
|
||||||
So $k = n / e$ and $n / k = e \approx 2.7$
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
If we try to approximate this with integers, we get the same solution as above.
|
|
||||||
\end{solution}
|
|
||||||
\end{document}
|
|
47
src/Warm-Ups/Partition Products/main.typ
Normal file
47
src/Warm-Ups/Partition Products/main.typ
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
|
||||||
|
#show: doc => handout(
|
||||||
|
doc,
|
||||||
|
quarter: link(
|
||||||
|
"https://betalupi.com/handouts",
|
||||||
|
"betalupi.com/handouts",
|
||||||
|
),
|
||||||
|
|
||||||
|
title: [Warm-Up: Partition Products],
|
||||||
|
by: "Mark",
|
||||||
|
)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Take any positive integer $n$. \
|
||||||
|
Now, write it as sum of smaller positive integers: $n = a_1 + a_2 + ... a_k$ \
|
||||||
|
Maximize the product $a_1 #sym.times a_2 #sym.times ... #sym.times a_k$
|
||||||
|
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
*Interesting Solution:*
|
||||||
|
|
||||||
|
Of course, all $a_i$ should be greater than $1$. \
|
||||||
|
Also, all $a_i$ should be smaller than four, since $x <= x(x-2)$ if $x >= 4$. \
|
||||||
|
Thus, we're left with sequences that only contain 2 and 3. \
|
||||||
|
#note([Note that two twos are the same as one four, but we exclude fours for simplicity.])
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
Finally, we see that $3^2 > 2^3$, so any three twos are better repackaged as two threes. \
|
||||||
|
The best sequence $a_i$ thus consists of a maximal number of threes followed by 0, 1, or 2 twos.
|
||||||
|
|
||||||
|
#v(8mm)
|
||||||
|
|
||||||
|
*Calculus Solution:*
|
||||||
|
|
||||||
|
First, solve this problem for equal, real $a_i$:
|
||||||
|
#v(2mm)
|
||||||
|
We know $n = product(a_i)$, thus $ln(n) = sum(ln(a_i))$. \
|
||||||
|
If all $a_i$ are equal, we get $ln(n) = k #sym.times ln(n / k)$. \
|
||||||
|
Derive wrt $k$ and set to zero to get $ln(n / k) = 1$ \
|
||||||
|
So $k = n / e$ and $n / k = e #sym.approx 2.7$
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
If we try to approximate this with integers, we get the same solution as above.
|
||||||
|
])
|
@ -1,34 +0,0 @@
|
|||||||
\documentclass[
|
|
||||||
solutions,
|
|
||||||
singlenumbering,
|
|
||||||
nopagenumber,
|
|
||||||
hidewarning
|
|
||||||
]{../../../lib/tex/ormc_handout}
|
|
||||||
\usepackage{../../../lib/tex/macros}
|
|
||||||
|
|
||||||
\title{Warm-Up: Prime Factors}
|
|
||||||
\uptitler{\smallurl{}}
|
|
||||||
\subtitle{Prepared by Mark on \today.}
|
|
||||||
|
|
||||||
\begin{document}
|
|
||||||
|
|
||||||
\maketitle
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
What proportion of integers have $2$ as their smallest prime factor?
|
|
||||||
% 1^2
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
What proportion of integers have $3$ as their second-smallest prime factor?
|
|
||||||
% 1/6
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
What is the median second-smallest prime factor?
|
|
||||||
% 37
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
\end{document}
|
|
29
src/Warm-Ups/Prime Factors/main.typ
Normal file
29
src/Warm-Ups/Prime Factors/main.typ
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
|
||||||
|
#show: doc => handout(
|
||||||
|
doc,
|
||||||
|
quarter: link(
|
||||||
|
"https://betalupi.com/handouts",
|
||||||
|
"betalupi.com/handouts",
|
||||||
|
),
|
||||||
|
|
||||||
|
title: [Warm-Up: Prime Factors],
|
||||||
|
by: "Mark",
|
||||||
|
)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
What proportion of integers have $2$ as their smallest prime factor?
|
||||||
|
#solution([$1 div 2$])
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
What proportion of integers have $3$ as their second-smallest prime factor?
|
||||||
|
#solution([$1 div 6$])
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
What is the median second-smallest prime factor?
|
||||||
|
#solution([37])
|
||||||
|
#v(1fr)
|
@ -1,153 +0,0 @@
|
|||||||
\documentclass[
|
|
||||||
solutions,
|
|
||||||
hidewarning,
|
|
||||||
]{../../../lib/tex/ormc_handout}
|
|
||||||
\usepackage{../../../lib/tex/macros}
|
|
||||||
|
|
||||||
|
|
||||||
\usepackage{xcolor}
|
|
||||||
\usepackage{soul}
|
|
||||||
\usepackage{hyperref}
|
|
||||||
|
|
||||||
\definecolor{Light}{gray}{.90}
|
|
||||||
\sethlcolor{Light}
|
|
||||||
\newcommand{\htexttt}[1]{\texttt{\hl{#1}}}
|
|
||||||
|
|
||||||
|
|
||||||
\title{The Regex Warm-Up}
|
|
||||||
\uptitler{\smallurl{}}
|
|
||||||
\subtitle{Prepared by Mark on \today}
|
|
||||||
|
|
||||||
\begin{document}
|
|
||||||
|
|
||||||
\maketitle
|
|
||||||
|
|
||||||
|
|
||||||
Last time, we discussed Deterministic Finite Automata. One interesting application of these mathematical objects is found in computer science: Regular Expressions. \par
|
|
||||||
This is often abbreviated \say{regex}, which is pronounced like \say{gif.}
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
Regex is a language used to specify patterns in a string. You can think of it as a concise way to define a DFA, using text instead of a huge graph. \par
|
|
||||||
|
|
||||||
Often enough, a clever regex pattern can do the work of a few hundred lines of code.
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
Like the DFAs we've studied, a regex pattern \textit{accepts} or \textit{rejects} a string. However, we don't usually use this terminology with regex, and instead say that a string \textit{matches} or \textit{doesn't match} a pattern.
|
|
||||||
|
|
||||||
\vspace{5mm}
|
|
||||||
|
|
||||||
Regex strings consist of characters, quantifiers, sets, and groups.
|
|
||||||
|
|
||||||
\vspace{5mm}
|
|
||||||
|
|
||||||
\textbf{Quantifiers} \par
|
|
||||||
Quantifiers specify how many of a character to match. \par
|
|
||||||
There are four of these: \htexttt{+}, \htexttt{*}, \htexttt{?}, and \htexttt{\{ \}}
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
\htexttt{+} means \say{match one or more of the preceding token} \par
|
|
||||||
\htexttt{*} means \say{match zero or more of the preceding token}
|
|
||||||
|
|
||||||
For example, the pattern \htexttt{ca+t} will match the following strings:
|
|
||||||
\begin{itemize}
|
|
||||||
\item \texttt{cat}
|
|
||||||
\item \texttt{caat}
|
|
||||||
\item \texttt{caaaaaaaat}
|
|
||||||
\end{itemize}
|
|
||||||
\htexttt{ca+t} will \textbf{not} match the string \texttt{ct}. \par
|
|
||||||
The pattern \htexttt{ca*t} will match all the strings above, including \texttt{ct}.
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
|
|
||||||
\htexttt{?} means \say{match one or none of the preceding token} \par
|
|
||||||
The pattern \htexttt{linea?r} will match only \texttt{linear} and \texttt{liner}.
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
Brackets \htexttt{\{min, max\}} are the most flexible quantifier. \par
|
|
||||||
They specify exactly how many tokens to match: \par
|
|
||||||
\htexttt{ab\{2\}a} will match only \texttt{abba}. \par
|
|
||||||
\htexttt{ab\{1,3\}a} will match only \texttt{aba}, \texttt{abba}, and \texttt{abbba}. \par
|
|
||||||
% spell:off
|
|
||||||
\htexttt{ab\{2,\}a} will match any \texttt{ab...ba} with at least two \texttt{b}s.
|
|
||||||
% spell:on
|
|
||||||
|
|
||||||
\vspace{5mm}
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
Write the patterns \htexttt{a*} and \htexttt{a+} using only \htexttt{\{ \}}.
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
Draw a DFA equivalent to the regex pattern \htexttt{01*0}.
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
\pagebreak
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\textbf{Characters, Sets, and Groups} \par
|
|
||||||
In the previous section, we saw how we can specify characters literally: \par
|
|
||||||
\texttt{a+} means \say{one or more \texttt{a} character}
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
There are, of course, other ways we can specify characters.
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
The first such way is the \textit{set}, denoted \htexttt{[ ]}. A set can pretend to be any character inside it. \par
|
|
||||||
For example, \htexttt{m[aoy]th} will match \texttt{math}, \texttt{moth}, or \texttt{myth}. \par
|
|
||||||
\htexttt{a[01]+b} will match \texttt{a0b}, \texttt{a111b}, \texttt{a1100110b}, and any other similar string. \par
|
|
||||||
You may negate a set with a \htexttt{\textasciicircum}. \par
|
|
||||||
\htexttt{[\textasciicircum abc]} will match any character except \texttt{a}, \texttt{b}, or \texttt{c}, including symbols and spaces.
|
|
||||||
|
|
||||||
\vspace{2mm}
|
|
||||||
|
|
||||||
If we want to keep characters together, we can use the \textit{group}, denoted \htexttt{( )}. \par
|
|
||||||
|
|
||||||
Groups work exactly as you'd expect, representing an atomic\footnotemark{} group of characters. \par
|
|
||||||
\htexttt{a(01)+b} will match \texttt{a01b} and \texttt{a010101b}, but will \textbf{not} match \texttt{a0b}, \texttt{a1b}, or \texttt{a1100110b}.
|
|
||||||
|
|
||||||
\footnotetext{In other words, \say{unbreakable}}
|
|
||||||
|
|
||||||
|
|
||||||
\problem{}<regex>
|
|
||||||
You are now familiar with most of the tools regex has to offer. \par
|
|
||||||
Write patterns that match the following strings:
|
|
||||||
\begin{enumerate}[itemsep=1mm]
|
|
||||||
\item An ISO-8601 date, like \texttt{2022-10-29}. \par
|
|
||||||
\hint{Invalid dates like \texttt{2022-13-29} should also be matched.}
|
|
||||||
|
|
||||||
\item An email address. \par
|
|
||||||
\hint{Don't forget about subdomains, like \texttt{math.ucla.edu}.}
|
|
||||||
|
|
||||||
\item A UCLA room number, like \texttt{MS 5118} or \texttt{Kinsey 1220B}.
|
|
||||||
|
|
||||||
\item Any ISBN-10 of the form \texttt{0-316-00395-7}. \par
|
|
||||||
\hint{Remember that the check digit may be an \texttt{X}. Dashes are optional.}
|
|
||||||
|
|
||||||
\item A word of even length. \par
|
|
||||||
\hint{The set \texttt{[A-z]} contains every english letter, capitalized and lowercase. \\
|
|
||||||
\texttt{[a-z]} will only match lowercase letters.}
|
|
||||||
|
|
||||||
\item A word with exactly 3 vowels. \par
|
|
||||||
\hint{The special token \texttt{\textbackslash w} will match any word character. It is equivalent to \texttt{[A-z0-9\_]} \\ \texttt{\_} stands for a literal underscore.}
|
|
||||||
|
|
||||||
\item A word that has even length and exactly 3 vowels.
|
|
||||||
|
|
||||||
\item A sentence that does not start with a capital letter.
|
|
||||||
\end{enumerate}
|
|
||||||
|
|
||||||
\vfill
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
If you'd like to know more, check out \url{https://regexr.com}. It offers an interactive regex prompt, as well as a cheatsheet that explains every other regex token there is. \par
|
|
||||||
You will find a nice set of challenges at \url{https://alf.nu/RegexGolf}.
|
|
||||||
I especially encourage you to look into this if you are interested in computer science.
|
|
||||||
\end{document}
|
|
141
src/Warm-Ups/Regex/main.typ
Normal file
141
src/Warm-Ups/Regex/main.typ
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
|
||||||
|
#show: doc => handout(
|
||||||
|
doc,
|
||||||
|
quarter: link(
|
||||||
|
"https://betalupi.com/handouts",
|
||||||
|
"betalupi.com/handouts",
|
||||||
|
),
|
||||||
|
|
||||||
|
title: [The Regex Warm-Up],
|
||||||
|
by: "Mark",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Last time, we discussed Deterministic Finite Automata. One interesting application of these mathematical objects is found in computer science: Regular Expressions. \
|
||||||
|
This is often abbreviated "regex," which is pronounced like "gif."
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
Regex is a language used to specify patterns in a string. You can think of it as a concise way to define a DFA, using text instead of a huge graph. \
|
||||||
|
|
||||||
|
Often enough, a clever regex pattern can do the work of a few hundred lines of code.
|
||||||
|
|
||||||
|
#v(2mm)
|
||||||
|
|
||||||
|
Like the DFAs we've studied, a regex pattern _accepts_ or _rejects_ a string. However, we don't usually use this terminology with regex, and instead say that a string _matches_ or _doesn't match_ a pattern.
|
||||||
|
|
||||||
|
#v(5mm)
|
||||||
|
|
||||||
|
Regex strings consist of characters, quantifiers, sets, and groups.
|
||||||
|
|
||||||
|
#v(5mm)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*Quantifiers* \
|
||||||
|
Quantifiers specify how many of a character to match. \
|
||||||
|
There are four of these: `+`, `*`, `?`, and `{ }`.
|
||||||
|
|
||||||
|
#v(4mm)
|
||||||
|
|
||||||
|
`+` means "match one or more of the preceding token" \
|
||||||
|
`*` means "match zero or more of the preceding token"
|
||||||
|
|
||||||
|
For example, the pattern `ca+t` will match the following strings:
|
||||||
|
- `cat`
|
||||||
|
- `caat`
|
||||||
|
- `caaaaaaaat`
|
||||||
|
`ca+t` will *not* match the string `ct`. \
|
||||||
|
The pattern `ca*t` will match all the strings above, including `ct`.
|
||||||
|
|
||||||
|
|
||||||
|
#v(4mm)
|
||||||
|
|
||||||
|
|
||||||
|
`?` means "match one or none of the preceding token" \
|
||||||
|
The pattern `linea?r` will match only `linear` and `liner`.
|
||||||
|
|
||||||
|
#v(4mm)
|
||||||
|
|
||||||
|
Brackets `{min, max}` are the most flexible quantifier. \
|
||||||
|
They specify exactly how many tokens to match: \
|
||||||
|
`ab{2}a` will match only `abba`. \
|
||||||
|
`ab{1,3}a` will match only `aba`, `abba`, and `abbba`. \
|
||||||
|
`ab{2,}a` will match any `ab...ba` with at least two `b`s. // spell:disable-line
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Write the patterns `a*` and `a+` using only `{ }`.
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Draw a DFA equivalent to the regex pattern `01*0`.
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#pagebreak()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*Characters, Sets, and Groups* \
|
||||||
|
In the previous section, we saw how we can specify characters literally: \
|
||||||
|
`a+` means "one or more `a` characters" \
|
||||||
|
There are, of course, other ways we can specify characters.
|
||||||
|
|
||||||
|
#v(4mm)
|
||||||
|
|
||||||
|
The first such way is the _set_, denoted `[ ]`. A set can pretend to be any character inside it. \
|
||||||
|
For example, `m[aoy]th` will match `math`, `moth`, or `myth`. \
|
||||||
|
`a[01]+b` will match `a0b`, `a111b`, `a1100110b`, and any other similar string. \
|
||||||
|
|
||||||
|
#v(4mm)
|
||||||
|
|
||||||
|
We can negate a set with a `^`. \
|
||||||
|
`[^abc]` will match any single character except `a`, `b`, or `c`, including symbols and spaces.
|
||||||
|
|
||||||
|
#v(4mm)
|
||||||
|
|
||||||
|
If we want to keep characters together, we can use the _group_, denoted `( )`. \
|
||||||
|
|
||||||
|
Groups work exactly as you'd expect, representing an atomic#footnote([In other words, "unbreakable"]) group of characters. \
|
||||||
|
`a(01)+b` will match `a01b` and `a010101b`, but will *not* match `a0b`, `a1b`, or `a1100110b`.
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
You are now familiar with most of the tools regex has to offer. \
|
||||||
|
Write patterns that match the following strings:
|
||||||
|
|
||||||
|
- An ISO-8601 date, like `2022-10-29`. \
|
||||||
|
#hint([Invalid dates like `2022-13-29` should also be matched.])
|
||||||
|
|
||||||
|
- An email address. \
|
||||||
|
#hint([Don't forget about subdomains, like `math.ucla.edu`.])
|
||||||
|
|
||||||
|
- A UCLA room number, like `MS 5118` or `Kinsey 1220B`.
|
||||||
|
|
||||||
|
- Any ISBN-10 of the form `0-316-00395-7`. \
|
||||||
|
#hint([Remember that the check digit may be an `X`. Dashes are optional.])
|
||||||
|
|
||||||
|
- A word of even length. \
|
||||||
|
#hint([
|
||||||
|
The set `[A-z]` contains every english letter, capitalized and lowercase. \
|
||||||
|
`[a-z]` will only match lowercase letters.
|
||||||
|
])
|
||||||
|
|
||||||
|
- A word with exactly 3 vowels. \
|
||||||
|
#hint([
|
||||||
|
The special token `\w` will match any word character. \
|
||||||
|
It is equivalent to `[A-z0-9_]`. `_` represents a literal underscore.
|
||||||
|
])
|
||||||
|
|
||||||
|
- A word that has even length and exactly 3 vowels.
|
||||||
|
|
||||||
|
- A sentence that does not start with a capital letter.
|
||||||
|
#v(1fr)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
If you'd like to know more, check out `https://regexr.com`.
|
||||||
|
It offers an interactive regex prompt,
|
||||||
|
as well as a cheatsheet that explains every other regex token there is. \
|
||||||
|
You can find a nice set of challenges at `https://alf.nu/RegexGolf`.
|
@ -1,30 +0,0 @@
|
|||||||
\documentclass[
|
|
||||||
solutions,
|
|
||||||
singlenumbering,
|
|
||||||
nopagenumber
|
|
||||||
]{../../../lib/tex/ormc_handout}
|
|
||||||
\usepackage{../../../lib/tex/macros}
|
|
||||||
|
|
||||||
\title{Warm-Up: Travellers}
|
|
||||||
\uptitler{\smallurl{}}
|
|
||||||
\subtitle{Prepared by Mark on \today}
|
|
||||||
|
|
||||||
\begin{document}
|
|
||||||
|
|
||||||
\maketitle
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
Four travellers are on a plane, each moving along a straight line at an arbitrary constant speed. \par
|
|
||||||
No two of their paths are parallel, and no three intersect at the same point. \par
|
|
||||||
We know that traveller A has met travelers B, C, and D, \par
|
|
||||||
and that traveller B has met C and D (and A). Show that C and D must also have met. \par
|
|
||||||
|
|
||||||
\begin{solution}
|
|
||||||
When a body travels at a constant speed, its graph with respect to time is a straight line. \par
|
|
||||||
So, we add time axis in the third dimension, perpendicular to our plane. \par
|
|
||||||
Naturally, the projection of each of these onto the plane corresponds to a road.
|
|
||||||
|
|
||||||
Now, note that two intersecting lines define a plane and use the conditions in the problem to show that no two lines are parallel.
|
|
||||||
\end{solution}
|
|
||||||
|
|
||||||
\end{document}
|
|
26
src/Warm-Ups/Travellers/main.typ
Normal file
26
src/Warm-Ups/Travellers/main.typ
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
|
||||||
|
#show: doc => handout(
|
||||||
|
doc,
|
||||||
|
quarter: link(
|
||||||
|
"https://betalupi.com/handouts",
|
||||||
|
"betalupi.com/handouts",
|
||||||
|
),
|
||||||
|
|
||||||
|
title: [Warm-Up: Travellers],
|
||||||
|
by: "Mark",
|
||||||
|
)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
Four travellers are on a plane, each moving along a straight line at an arbitrary constant speed. \
|
||||||
|
No two of their paths are parallel, and no three intersect at the same point. \
|
||||||
|
We know that traveller A has met travelers B, C, and D, \
|
||||||
|
and that traveller B has met C and D (and A). Show that C and D must also have met.
|
||||||
|
|
||||||
|
#solution([
|
||||||
|
When a body travels at a constant speed, its graph with respect to time is a straight line. \
|
||||||
|
So, we add time axis in the third dimension, perpendicular to our plane. \
|
||||||
|
Naturally, the projection of each of these onto the plane corresponds to a road.
|
||||||
|
|
||||||
|
Now, note that two intersecting lines define a plane and use the conditions in the problem to show that no two lines are parallel.
|
||||||
|
])
|
@ -1,22 +0,0 @@
|
|||||||
\documentclass[
|
|
||||||
solutions,
|
|
||||||
hidewarning,
|
|
||||||
singlenumbering,
|
|
||||||
nopagenumber
|
|
||||||
]{../../../lib/tex/ormc_handout}
|
|
||||||
\usepackage{../../../lib/tex/macros}
|
|
||||||
|
|
||||||
|
|
||||||
\title{Warm-Up: \texttt{fmod}}
|
|
||||||
\uptitler{\smallurl{}}
|
|
||||||
\subtitle{Prepared by Mark on \today.}
|
|
||||||
|
|
||||||
\begin{document}
|
|
||||||
|
|
||||||
\maketitle
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
I'm sure you're all familiar with how \texttt{mod(a, b)} and \texttt{remainder(a, b)} work with integers. \par
|
|
||||||
Devise an equivalent for floats (i.e, real numbers).
|
|
||||||
|
|
||||||
\end{document}
|
|
16
src/Warm-Ups/fmod/main.typ
Normal file
16
src/Warm-Ups/fmod/main.typ
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#import "@local/handout:0.1.0": *
|
||||||
|
|
||||||
|
#show: doc => handout(
|
||||||
|
doc,
|
||||||
|
quarter: link(
|
||||||
|
"https://betalupi.com/handouts",
|
||||||
|
"betalupi.com/handouts",
|
||||||
|
),
|
||||||
|
|
||||||
|
title: [Warm-Up: `fmod`],
|
||||||
|
by: "Mark",
|
||||||
|
)
|
||||||
|
|
||||||
|
#problem()
|
||||||
|
I'm sure you're all familiar with how `mod(a, b)` and `remainder(a, b)` \ work when `a` and `b` are integers.
|
||||||
|
Devise an equivalent for floats (i.e, real numbers).
|
@ -143,10 +143,12 @@ def build_typst(source_dir: Path, out_subdir: Path) -> IndexEntry | None:
|
|||||||
[
|
[
|
||||||
TYPST_PATH,
|
TYPST_PATH,
|
||||||
"compile",
|
"compile",
|
||||||
|
"--package-path",
|
||||||
|
f"{ROOT}/lib/typst",
|
||||||
"--ignore-system-fonts",
|
"--ignore-system-fonts",
|
||||||
"main.typ",
|
|
||||||
"--input",
|
"--input",
|
||||||
"show_solutions=false",
|
"show_solutions=false",
|
||||||
|
"main.typ",
|
||||||
f"{out}/{handout_file}",
|
f"{out}/{handout_file}",
|
||||||
],
|
],
|
||||||
cwd=source_dir,
|
cwd=source_dir,
|
||||||
@ -164,6 +166,8 @@ def build_typst(source_dir: Path, out_subdir: Path) -> IndexEntry | None:
|
|||||||
[
|
[
|
||||||
TYPST_PATH,
|
TYPST_PATH,
|
||||||
"compile",
|
"compile",
|
||||||
|
"--package-path",
|
||||||
|
f"{ROOT}/lib/typst",
|
||||||
"--ignore-system-fonts",
|
"--ignore-system-fonts",
|
||||||
"main.typ",
|
"main.typ",
|
||||||
f"{out}/{solutions_file}",
|
f"{out}/{solutions_file}",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user