Skip to content

Mathematical Basics notebook, Part 1: calculator, variables, number systems - #10

Merged
AronT-TLV merged 28 commits into
mainfrom
content/mathematical-basics
Oct 25, 2026
Merged

AronT-TLV merged 28 commits into
mainfrom
content/mathematical-basics

Conversation

@AronT-TLV

Copy link
Copy Markdown
Member

This PR adds the first study notebook, notebooks/MathematicalBasicsPart1.ipynb, which covers the first three chapters of the CWJSN Mathematical basics section. It also adds the package helpers the notebook uses.

The PR was planned for the end of the section. It opens at the halfway point instead: the three chapters done make up about half of the section's text, and the notebook would roughly double by the end. Part 2 (logical_expressions, vectors, ranges) will be a separate notebook on a new branch.

The notebook

Following docs/src/index.md, it holds only what is new in Julia or the math, plus commentary on points in CWJSN that need clarifying. The basics themselves are in Math_Foundations.

Chapter Sections
From calculator to computer Big numbers; Factorial; Numeric literals (numerals written in Julia syntax); Logarithms in Julia vs on paper; Questions
Variables Variable gotchas (x + y = 3 shadowing, world age); Euler's number: ℯ, not CWJS's e; Questions
Number systems The broadcasting dot; overflow vs rounding and ≈; abstract and concrete types; scientific notation in base 10 vs base 2; Euler's formula and complex numbers; symbols (interned strings, symbols vs enums); type stability (M2 Max vs Intel timings); powers with a numeric literal as the exponent; Questions

Each chapter ends with a Questions cell that answers the CWJSN chapter questions from a REPL session. The notebook is committed with its outputs, as in the sister repos.

Package and docs

File Change
src/calculus_basic.jl, src/Calculus.jl First source file: the notebook display helpers attempt, latex_error, latex_cell and latex_type, exported and documented by the existing @autodocs block
test/test_calculus_basic.jl Tests for the helpers replace the placeholder (suite: 44 pass)
docs/make.jl warnonly = Documenter.except(:autodocs_block) removed. Its comment said it kept the build strict, but except does the opposite and made every check except one warn-only. The build is now fully strict, as in Math_Foundations and Linear_Algebra
docs/src/index.md New ## Notebooks section: why the commentary lives in notebooks, and a link to Part 1
notebooks/Project.toml [sources] Calculus = {path = ".."} so the notebook environment uses this checkout
.github/instructions/project.instructions.md Source and test file descriptions brought up to date

Checks run locally (Julia 1.13.2)

  • Pkg.test(): 44/44 pass
  • julia --project=docs docs/make.jl (strict): exit 0. The only warnings are HTMLWriter size warnings (the CWJS API page and @example HTML output), not Documenter check failures

The notebook link in index.md points at main, so it resolves only after merge.

🤖 Generated with Claude Code

AronT-TLV and others added 28 commits October 2, 2026 15:19
Pkg on Julia 1.13.1 writes the dev'd package into [sources], so a fresh clone can
`instantiate` the notebooks environment without a manual `dev ..` first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, big integers)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k LaTeX block

attempt(f) returns f() or the exception it threw (rethrowing InterruptException), so a
notebook cell can show an error instead of stopping. latex_error turns an error message
into LaTeX lines for an L"""\begin{array}{l} ... \end{array}""" block: backticked parts
in \mathtt, LaTeX specials escaped, a line per "; " clause. Exported, documented by the
existing @autodocs block in docs/src/index.md, and tested -- the real factorial(21)
error is checked for structure, not Julia's wording. The project instructions no longer
call calculus_basic.jl and its tests placeholders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rom the package

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ok results table

latex_cell(r) turns a value, or an error caught by attempt, into one table entry:
\text{error}, true/false in \mathtt, exact ratios as \frac, Inf/-Inf/NaN as symbols, a
symlim route Symbol in \mathtt, a Num through CWJS's conventional_latex, text escaped.
latex_type(r) sets the type in \mathtt with a parametric type's braces escaped, so
Rational{Int64} keeps them. Exported, documented through the existing @autodocs block,
23 new tests (44 in all), inputs from the real producers: attempt results and a symlim
result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each of attempt, latex_error, latex_cell and latex_type ends its docstring with an
"Author: Claude" line, so the published docs say who wrote them (Aron's rule: a
function Claude writes says so). The file header states the convention.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pi^(2pi)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…or the basics; notebook continues

index.md says what the PreCalc notebook includes (what is new in Julia or the math,
plus clarifications of CWJSN) and that the basics are covered in Math_Foundations and
its Basics notebook; the overview no longer says there is no code or notebooks; Basic
Calculus notes that functions written by Claude are marked as such. The PreCalc link
points at main and resolves once this branch merges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nterexample"

Verzani's recommendation to use floats for large values, weighed against their exact range
(2^53, smaller than Int64's), with two recommendations in its place; the Homer Simpson
example computed as Int64, Float64 and BigInt. Two typos fixed ("teh", "recommendation").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`Documenter.except(:autodocs_block)` made every check warn-only EXCEPT
autodocs -- the opposite of what its comment claimed. It came from
upstream CalculusWithJulia.jl v0.1.3 via CWJS. A strict build passes,
so use Documenter's default, as Math_Foundations and Linear_Algebra do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ns table

Title is now "Mathematical Basics", with "From Calculator to Computer
Chapter" as the section. Adds a table of the CWJSN calculator chapter's
questions: each as written, how I wrote it in Julia, the answer, and the
experiments that show why the other choices are wrong.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lows

The notebook now covers the CWJSN "Mathematical basics" section and gets
its own PR when that section is done, so the file, the docs heading and
the link take its name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A let block keeps the shadowing local; at global scope const (+) = Base.:+
reattaches the name, after which re-running the definition extends Base's
own +. The next cell adds that method and removes it with Base.delete_method.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CalculusWithJuliaSquared exports e = exp(1), a Float64, inherited from
upstream CalculusWithJulia; Julia's ℯ is an Irrational. The cell tables
where they differ (exp, log, big, symbolic powers, derivatives, products)
on Julia 1.13.2. Also a println in the delete_method cell, and the
notebook re-run on the Julia 1.13.2 kernel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MathematicalBasics.ipynb: the CWJSN variables Questions answer table (from
Aron's REPL session; options he skipped run and marked *), and the heading
for the next chapter, Number Systems.

docs/src/index.md: the Notebooks section explains why the commentary lives in
the notebooks rather than the docs (CWJSN is Verzani's text), and that the
notebooks expand on CWJSN, on Julia and on the CWJS package, not only
exercises.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g, ≈

Some Gotchas for CWJSN basics/numbers_types: what 1., 2. * 3, 2 .* 3 and
2.*3 parse to (broadcasting is first explained later, in vectors); why
integer overflow and float rounding share a cause but not a fix (big removes
overflow, only shrinks rounding); tables of examples, and == versus ≈,
including the atol needed to compare with zero. Measured on Julia 1.13.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e types

Adds a sin(1pi) row to the overflow/rounding table (1pi is the Float64
nearest π; sin(pi) hits Base's special method) and a cell explaining
abstract, concrete and parametric types, the type tree, and supertypes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds a cell on why CWJSN writes floats as a·2^b while the linked
Wikipedia article uses a·10^b, with significand/exponent values and
why 0.1 is inexact in base 2; a colon disambiguates the Verzani remark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ulus

Cell 42: Euler's formula and identity (Feynman, Burger), transcendence
(Lindemann, Gelfond's constant), why e^{iπ} = -1, two calculus proofs,
and how advanced calculus uses it (defining sin/cos, trig identities,
integrals), with numerical checks in Julia 1.13.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…enums

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Verzani's premise that shorter instruction lists run faster is tested with
a sum over Vector{Int} and Vector{Any}: 50 vs 69 native instructions, but
about 250x slower, from run-time dispatch and boxing that the listing does
not show. Knowing the types lets the compiler decide once, while compiling,
what would otherwise be decided on every step while running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The same sum run on an Intel i5-8500B (2018) and the M2 Max, both on
Julia 1.13.2: the untyped penalty is about 330x on Intel against about
180x on the M2 Max, and on Intel the typed listing is the longer one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Numeric Literals: define numerals vs numbers vs names, table of what Julia
parses as a literal. New "Powers: a numeric literal as the exponent" cell
(2^-1 vs 2^b, Base.literal_pow, type stability). CWJSN numbers_types
Questions answer cell. "Try to answer…" line in all three Questions cells.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rial is split

Rename MathematicalBasics.ipynb to MathematicalBasicsPart1.ipynb and retitle it
"Mathematical Basics - Part 1": it covers the first three CWJSN basics chapters
(calculator, variables, numbers_types). index.md links Part 1 and says Part 2 is
in progress.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AronT-TLV
AronT-TLV merged commit e4d93c1 into main Oct 25, 2026
5 checks passed
@AronT-TLV
AronT-TLV deleted the content/mathematical-basics branch October 25, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant