Welcome to Functional Calculator!
Learn more about this project at
github.com/rohanphanse/calculator .
1. Variables and Functions
`a = 3`
Variable `a` declared
`f(x) = x^2 - 12x + 27`
Function `f` declared
Use
save to locally save variables and functions.
2. Commands and Keyboard
Commands:
Clear screen: clear
Last result: ans
Usage help: help
Debug trace: trace
Plot 2D graphs: plot
Plot 3D graphs: plot3
Differentiation: diff
Numerical Limit: lim
`diff x^2 * sin(x)`
`f'(x) = 2x * sin(x) +
x^2 * cos(x)`
Derivative `f'` declared
Keyboard:
Shift + enter: decimal answer
Up arrow: move back in history
Down arrow: move forward
Click
plot to learn how to graph functions, parametric + polar curves, and slope + vector fields!
3. Math
Math Operators:
These operators support tensors, fractions, base systems, and units.
`[1, 2, 3] + 3[1, 0, -1]`
`[4, 2, 0]`
`3/4 * 3 - 10/6`
`7/12`
`3 mi + 5 km`
`6.106864 mi`
`ans to ft`
`32244.16 ft`
`0xf - 0b111 - 0o7`
`1`
Math Functions and Constants:
Trigonometry:
sin
cos
tan
arcsin
arccos
`log(10) + log(2, 8)`
`4`
`1 + sin(pi/2) + ln(e^-2)`
`0`
Linear Algebra:
`M = [[1, 2], [2, 1]]`
Variable `M` declared
`det(M)`
`-3`
`inv(M)`
`[[-0.3333, 0.6667],`
`[0.6667, -0.3333]]`
`eigen(M)`
Declared: `λ1 = 3, v1 =`
`[0.707107, 0.707107]`
`λ2 = -1, v2 = [0.707107,`
`-0.707107]`
`v1`
`[[0.7071],`
` [0.7071]]`
Complex Analysis:
conj
re
im
sinh
cosh
tanh
`e^(i*pi)`
`-1`
`sinh(1 + i)`
`0.634964 + 1.29846i`
Statistics:
Bitwise Operations:
Boolean Operators:
Miscellaneous:
`quad(f)`
`x^2 - 12x + 27 = 0`
Roots: `x = 9` or `x = 3`
4. Functional Programming
Functional Paradigms:
`map([1, 2, 3], @(x) = x^2)`
`[1, 4, 9]`
`p(n) = n mod 2 == 0`
Function `p` declared
`filter([2, 3, 4], p)`
`[2, 4]`
`reduce([1, 2, 3], +)`
`6`
@ is used for lambda functions, enabling two powerful paradigms: lambda capture and currying.
`add = @(a) = @(b) = a + b`
Variable `add` declared
`inc = add(1)`
Variable `inc` declared
`add(1)(2)`
`3`
`inc(10)`
`11`
Use conditional logic to help implement recursive functions.
`if false then 1 else if
true then 2 else 3`
`2`
`fact(n) = if n <= 1 then 1
else n * fact(n - 1)`
Function `fact` declared
`trace fact(3)`
`fact(3)
| fact(2)
| | fact(1) -> 1
| fact(2) -> 2
fact(3) -> 6`
5. Physics and Chemistry
Physical Constants:
Molar masses (source:
IUPAC ):
mH
mHe
mLi
mBe
mB
mC
mN
mO
mF
mNe
mNa
mMg
mAl
mSi
mP
mS
mCl
mAr
mK
mCa
mSc
mTi
mV
mCr
mMn
mFe
mCo
mNi
mCu
mZn
mGa
mGe
mAs
mSe
mBr
mKr
mRb
mSr
mY
mZr
mNb
mMo
mTc
mRu
mRh
mPd
mAg
mCd
mIn
mSn
mSb
mTe
mI
mXe
mCs
mBa
mLa
mCe
mPr
mNd
mPm
mSm
mEu
mGd
mTb
mDy
mHo
mEr
mTm
mYb
mLu
mHf
mTa
mW
mRe
mOs
mIr
mPt
mAu
mHg
mTl
mPb
mBi
mPo
mAt
mRn
mFr
mRa
mAc
mTh
mPa
mU
mNp
mPu
mAm
mCm
mBk
mCf
mEs
mFm
mMd
mNo
mLr
mRf
mDb
mSg
mBh
mHs
mMt
mDs
mRg
mCn
mNh
mFl
mMc
mLv
mTs
mOg
Show More
Use
bal to balance chemical equations.
`mH`
`1.008 gm/mol`
`mH2O`
`18.015 gm/mol`
`1 kg / mH2O`
`55.5092978074 mol`
`bal C2H6 + O2 = CO2 + H2O`
`2C2H6 + 7O2 → 4CO2 + 6H2O`
Units:
Length: km me cm mm um nm mi ft in au ly
Mass: kg gm mg lb oz
Time: se ms mn hr day wk yr
Energy: jl kj cal kcal ev
Volume: li ml gal
Temperature: kel cel far
Mechanics: ne pa atm wa
E&M: cu am om vo fa wb te he
Use
to to convert one unit in an expression to another. Use
si to convert an expression to SI units.
`u0`
`0.00000125663706127 ne/am^2`
`e0`
`8.8541878188e-12 fa/me`
`si 1 / sqrt(u0 * e0)`
`299792458 me/se`
`cc to km to ms`
`299.792458 km/ms`
6. Appendix
Learn which types built-in functions expect using
help and obtain types with
type .
`type(M)`
`list[list[number]]`
`map([sin, true, km], type)`
`[function, bool, unit]`
List utilities:
Note that list indexing is one-based and range is inclusive.
`M`
`[[1, 2],
[3, 4]]`
`M(2)`
`[3, 4]`
`M(2, 1)`
`3`
`M(:, 1)`
`[1, 3]`
`x = [2, 3, 5, 7]; x(2:)`
`[3, 5, 7]`
`range(2) == [1, 2]`
`true`
Use macros to type special characters:
→ \to
α \a
β \b
γ \g
Γ \G
δ \d
Δ \D
ϵ \e
η \h
ζ \z
θ \th
Θ \Th
ι \i
κ \k
λ \l
Λ \L
μ \m
ν \n
ξ \x
Ξ \X
π \pi
Π \Pi
ρ \r
σ \s
Σ \S
τ \tau
υ \u
ϕ \phi
Φ \Phi
χ \c
ψ \psi
Ψ \Psi
ω \o
Ω \O
Show More
Here's an implementation of the Sieve of Eratosthenes :).
`sieve(ls) = if ls == []
then [] else concat(ls(1),
sieve(filter(ls(2:),
@(x) = x mod ls(1))))`
Function `sieve` declared
`sieve(range(2, 17))`
`[2, 3, 5, 7, 11, 13, 17]`