math(n)
math(n) πβ¨
okay so bestie, welcome to the math(n) page, aka the Tcl Math Library β and yes it's as iconic as it sounds. sit down, grab a strawberry π, we're doing numbers today.
β¨ SYNOPSIS β¨
package require Tcl 8.5 9
package require math ?1.2.6?
::math::cov value value ?value ...?
::math::integrate list of xy value pairs
::math::fibonacci n
::math::max value ?value ...?
::math::mean value ?value ...?
::math::min value ?value ...?
::math::product value ?value ...?
::math::random ?value1? ?value2?
::math::sigma value value ?value ...?
::math::stats value value ?value ...?
::math::sum value ?value ...?
like. look at her. a whole roster. π
π¦ DESCRIPTION π¦
so the math package is your go-to girl for utility math functions. that's the vibe. π«Ά
but wait, there's more β besides this set of basic commands (which you get straight from the math package), there are a bunch of more specialised packages that are whole entire side quests. each one is its own main character:
math::bigfloatβ Arbitrary-precision floating-point arithmetic β¨math::bignumβ Arbitrary-precision integer arithmetic π’math::calculus::rombergβ Robust integration methods for functions of one variable, using Romberg integrationmath::calculusβ Integration of functions, solving ordinary differential equationsmath::combinatoricsβ Procedures for various combinatorial functions (for instance the Gamma function and "k out of n") πmath::complexnumbersβ Complex number arithmeticmath::complexnumbersβ¦ okay not repeating, next one:math::constantsβ A set of well-known mathematical constants, such as Pi, E, and the golden ratio πΈmath::fourierβ Discrete Fourier transformsmath::fuzzyβ Fuzzy comparisons of floating-point numbersmath::geometryβ 2D geometrical computations πmath::interpolateβ Various interpolation methodsmath::linearalgebraβ Linear algebra packagemath::optimizeβ Optimization methodsmath::polynomialsβ Polynomial arithmetic (includes families of classical polynomials)math::rationalfunctionsβ Arithmetic of rational functionsmath::romanβ Manipulation (including arithmetic) of Roman numerals ποΈmath::specialβ Approximations of special functions from mathematical physicsmath::statisticsβ Statistical operations and tests
okay so slight edit bestie, that list is exactly these, no more no less, don't let me gaslight you: math::bigfloat, math::bignum, math::calculus::romberg, math::calculus, math::combinatorics, math::complexnumbers, math::constants, math::fourier, math::fuzzy, math::geometry, math::interpolate, math::linearalgebra, math::optimize, math::polynomials, math::rationalfunctions, math::roman, math::special, math::statistics. periodt. π
π BASIC COMMANDS π
these are the day-ones. the ride-or-dies. the ones you get just by requiring math.
::math::cov value value ?value ...?β gives you the coefficient of variation, expressed as a percent, of two or more numeric values. (two minimum, bestie, it needs at least a duo.)::math::integrate list of xy value pairsβ returns the area under a "curve" defined by a set of x,y pairs, plus the error bound, all as a list. it's giving calculus but make it chill.::math::fibonacci nβ returns the n'th Fibonacci number. that's it. that's the tweet. β¨::math::max value ?value ...?β the maximum of one or more numeric values. the biggest one. the main character. π::math::mean value ?value ...?β the mean, or "average", of one or more numeric values. literally the average, no cap.::math::min value ?value ...?β the minimum of one or more numeric values. the smallest, but she still matters. π₯Ί::math::product value ?value ...?β the product of one or more numeric values. multiply, multiply, slay.::math::random ?value1? ?value2?β returns a random number. the deets:- no arguments at all? you get a floating point value between 0 and 1. π²
- one argument? you get an integer value between 0 and value1.
- two arguments? you get an integer value between value1 and value2.
::math::sigma value value ?value ...?β returns the sample standard deviation of two or more numeric values.::math::stats value value ?value ...?β returns the mean, standard deviation, and coefficient of variation (as percent) β all bundled up as a list. a little combo meal. π::math::sum value ?value ...?β the sum of one or more numeric values. adding things. iconic behaviour.
π BUGS, IDEAS, FEEDBACK π
ngl bestie, this document β and the package it describes β will undoubtedly contain bugs and other problems. it's not a vibe, it's just reality. π
so if you find one, please report it in the category math of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. π«Ά
also please send in any ideas for enhancements you may have for either the package and/or the documentation. we want the glow-up.
when you're proposing code changes, please provide unified diffs, i.e the output of diff -u. that's the format, don't freestyle it.
and one more thing β note further that attachments are strongly preferred over inlined patches. here's how you do it: go to the Edit form of the ticket immediately after its creation, and then use the left-most button in the secondary navigation bar. easy. π
π KEYWORDS π
math, statistics
β CATEGORY β
Mathematics
okay that's the whole page, you ate it up π and just so you know where this came from: it's from tcllib, version 1.2.6, page math(n). stan. bye bestie, go do some math π§β¨π
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms