# This document describes some of the functionality planned for Mu,
# as well as a class hierarchy to implement it.
+ denotes class/subclass
- denotes instance
# An Operable is anything that may used as an operand
# in an expression. A set of core methods is expected to
# be implemented by all Operables, e.g:
# * arithmetic operators
# * .simplify(), simplify if an Expr; otherwise, just evaluate to self
# * .mathml(), return a MathML representation of the object
# * .tex(), return a TeX representation of the object
+ Operable
+ Expr # Basically wrap a tuple (operator, args)
+ Symbol # An 'x'; a variable/undefined quantity
# Can't use Python's types directly since they won't interact
# with custom classes.
+ Int # Provides int's functionality
+ Real # Provides Decimal's functionality
+ Interval # Intervals of real numbers
+ Array # Note: Perhaps n-dimensional arrays are overkill.
# A Matrix type might suffice.
# The following three types may not be strictly necessary, since
# they can be expressed using Exprs. However, they may also
# simplify some code and make it much more efficient.
+ Rational
+ Complex
+ Polynomial
# Constants may be used as ordinary numbers in expressions. They
# can be evaluated to arbitrary numerical precision when necessary.
+ Constant
- infinity # compares as larger than all finite reals
- pi # 3.14159265358979...
- e # 2.71828182845904...
- gammac # 0.57721566490153...
- catalan # 0.91596559417721...
- goldenratio # 1.61803398874989...
...
# For pure convenience
- degree # pi/180
- percent # 0.01
- kilo # 1000
- nano # 0.000000001
...
# Units are not real numbers, but behave much like ordinary numerical
# constants. Units may impose restrictions on the expressions they appear
# in; for example, adding kilogram and second is illegal.
+ Unit
- imagi # imaginary unit; base of complex numbers
- quatj # quaternion unit j
- quatk # quaternion unit k
...
- kilogram # SI base and derived units
- second
- meter
- ampere
- kelvin
- mole
- candela
# Unlike regular Python functions, Functions can be type-overloaded
# and interact nicely with symbolic arguments. They can also be used as
# operands; e.g. 1/sin gives the function that maps x to 1/sin(x),
# and may provide rules for simplification/differentiation, etc.
+ Function
# Of real and complex arguments
- add, sub, mul, div, pow, mod
- sqrt, exp, log, log2, log10
- sin, cos, tan, asin, acos, atan
- sinh, cosh, tanh, asinh, acosh, atanh
- gamma, zeta
...
# XXX: maybe the Function abstraction is only useful for
# continuous, transcendental functions. The following could
# probably be implemented as regular Python functions as well,
# though on the other hand the difference in complexity really
# doesn't matter.
# Of integers, generally
- isprime
- primepi
- factorial
- multifactorial
- upfactorial
- downfactorial
- bincoef
...
# Sequences are a useful abstraction for infinite sequences of integers,
# rationals, polynomials, etc. Their main advantage over functions that
# compute the nth element directly is that the common operation of
# iterating over several elements can be performed efficiently.
# In addition, this provides a uniform interface for membership testing,
# set intersection, numerical estimation of the nth element, etc,
# as such operations can be provided as methods on the sequences instead
# of multiple stray functions for separate sequences.
+ Sequence
- naturals 0, 1, 2, 3, ...
- evens 0, 2, 4, 6, ...
- odds 1, 3, 5, 7, ...
- onoff 1, 0, 1, 0, ...
- altsign 1, -1, 1, -1, ...
- primes 2, 3, 5, 7, ...
- factorials 1, 1, 2, 6, ...
- fibonaccis 0, 1, 1, 2, ...
- bernoullis 1, -1/2, 1/6, -1/30, ...
+ PowerSeries, perhaps?