Repository navigation
Pycodemath 0.5.1
Fixes from a hands-on test session against 0.5.0 (49 CLI calls), plus a
first-run intro and commands for finding your way around.
Added
sum p(k)*binomial(n,k) for k from a to nwithpa polynomial ink: closed
form via Stirling numbers of the second kind,Σ_k k^m C(n,k) = Σ_j S(m,j) n!/(n-j)! 2^(n-j)(e.g.sum k^3*binomial(n,k) for k from 0 to n=
2**(n - 3)*n**2*(n + 3)). Proved by that identity; the result is also checked
against the brute-force sum before it is returned (tests: n = 0..20).- Definite integrals of the Bose–Einstein / Fermi–Dirac family on (0, oo):
∫ x^(s-1)/(e^(cx) - 1) = Γ(s)ζ(s)/c^s(s > 1) and∫ x^(s-1)/(e^(cx) + 1) = (1-2^(1-s))Γ(s)ζ(s)/c^s(s > 0), used where SymPy finds no closed form;
convergence is proved and the value cross-checked against the independent
quadrature as for every other definite integral (integrate x^3/(exp(x)-1) dx from 0 to oo=pi**4/15, VERIFIED, was a value without a closed form). - First run and way-finding.
pycodemath intro(alsopython -m pycodemath introandintroin the REPL): an 80-column header box with the
logo (rasterized fromassets/pycodemath-sygnet.svgbyscripts/gen_logo.py:
36 columns, stroke 12, transparent half blocks), the name, version, tagline
"Checks the math in your code.", the number of commands and API functions
(counted at run time), then one live demo (an off-by-one loop read as a
formula, REFUTED with the executed call, fixed, VERIFIED; every number comes
fromcheck_codeat run time) and a capability map of eight areas, each with
a runnable command. Animated only on a TTY, under 6 s;--static,
PYCODEMATH_NO_ANIM=1or a pipe print the final frame (30 lines, 80
columns). Truecolor, a 256-colour fallback mapped to the nearest palette
entries, monochrome underNO_COLORor off a TTY. Flags:--static,
--no-logo,--once. - The intro plays by itself once per installed version: on the first run of
pycodemath/python -m pycodemathwith a TTY stdout after installing or
upgrading, before the command's own output. Never off a TTY, never in the MCP
server, never withPYCODEMATH_NO_INTRO=1. The shown version is kept in
intro-shownin the user cache directory.pycodemath intro --onceshows it
only if this version's intro has not been shown yet, else prints nothing and
exits 0. pycodemath commands(every command by topic),pycodemath help <topic>
(the REPL help, cut by topic: solve, calculus, verify, code, numbers, money,
units, geometry, ode, stats, start),pycodemath examples <topic>(3-5
runnable examples each; a test runs every one) andpycodemath tour(five
short live demos; Enter = next, q = quit; sequential off a TTY).- MCP tool
intro: the logo as plain text, the tagline and the capability map
as text and data (no ANSI, no engine call). The existing tools are unchanged. assets/intro.svg, recorded from the real command by
scripts/record_intro_svg.py, in a new "First run" section of both READMEs.
Changed
money loan ... for N yearsis now a duration paid MONTHLY (N×12
instalments):money loan 300000 PLN at 7.2% for 25 yearsgives 300
instalments of 2158.77 PLN. 0.5.0 readyearsas N annual instalments
(26208.67 PLN) — what nobody taking a mortgage means. Annual instalments are
asked for explicitly:... for 25 years yearly(alsoannual,annually);
yearlywith a duration in months is refused. The answer now names the
schedule (300 monthly instalments: payment ...). Same on the CLI/REPL and
MCPmath_eval(whose description says so); the Python API
(amortization_schedule,annuity_payment) was never ambiguous — it takes
periodsandperiods_per_year— and is unchanged.money interestkeeps its meaning (the unit is the compounding period:
for 10 yearscompounds yearly,for 12 monthsmonthly) and the answer now
says so (compounded yearly, 10 years).dsolvewithout a closed form names the CLI command in its hint —solve it numerically instead (ode <expr> for y(t) from <t0> to <t1> at <y0>)— instead
of the Python functionsolve_ode_num, assolvealready namesroot.
routestays"ode".sum(...),Sum(...),summation(...),integrate(...),Integral(...)and
integral(...)inside an expression (verify sum(k, (k,0,n)) == ...,evalf integrate(x, (x,0,1)) 60) are refused with a pointer to thesum ... for k from .. to ../integrate ... dx from .. to ..commands instead of "write
sum*(...) if a product is meant".- The interactive REPL greets with a 2-line banner (the text mark
∫>_,
version, where to start). One-shot commands still print no banner off a TTY
— pinned by a test.
Fixed
sum p(k)*binomial(n,k)answers in about 2 s instead of about 95 s for
k^5: the proved rule now runs before SymPy, which used to grind until it
gave up.- The time budget no longer fires into cleanup code. When a deadline passed
while the thread was in a__del__, a gc callback or aweakref.finalize
finalizer, Python printedException ignored in ..., cut the cleanup short
and dropped the interrupt. The watchdog now waits for the cleanup to finish
and interrupts 50 ms later. This was also a flaky CI failure. solveandcertify solvetake an equation:solve x^2 = 4 for xand
solve x^2-5*x+6 == 0 for xare solved aslhs - rhs.==used to compare
the two sides as Python objects and printed "(no solutions)". An=anywhere
else in an expression is now aParseErrorthat points tosolve/verify.- Strict mode no longer guesses on
2abwhenaandbare also variables of
the same expression:verify (a+b)^2 == a^2 + 2ab + b^2came back REFUTED
(it readabas one variable). It is now aParseErrorasking fora*bor a
rename. Names likespeed,alphaor a loneabstill parse as before.