19. Chapter 1
Maxima Core
1.1 Mathematical
1.1.1 Factorial Symbol (!)
It represents to the factorial operator. A n! represents the factorial of n in form
of n × (n − 1) × . . . × 3 × 2 × 1. Factorial of negative number is infinity.
✞
1 (%i1) 5!
✆
The output is
✞
(%o1) 120
✆
Factorial of a fraction number in three place precision is
✞
1 (%i1) 0.5!
✆
The output is
✞
(%o1) 0.886
✆
Factorial of 0.5! is
√
π/2.
1.1.2 Double Factorial Symbol (!!)
It represents to the double factorial operator. A n!! represents the factorial
in form of n × (n − 2) × . . . × 5 × 3 × 1. If n is an odd number otherwise
n × (n − 2) × . . . × 4 × 2 if n is an even number.
✞
1 (%i1) 5!!
✆
The output is
✞
(%o1) 15
✆
19
20. 20 CHAPTER 1. MAXIMA CORE
1.1.3 Termination of Line (;)
Symbol ‘;’ (colon) is used to terminate a line in Maxima console. Every thing
written after the symbol ‘;’ is treated as comments and it is skipped by Maxima
during evaluation of transcript.
✞
1 (%i1) 5!!; double factorial
✆
The output is
✞
(%o1) 15
✆
1.1.4 Negation of Expression (#)
# represents negation of syntactic equality. Note that because of the rules for
evaluation of predicate expressions “not a = b” is equivalent tois(a # b) instead
of “a # b”.
1.1.5 Evaluate Internally & No Output ($)
$ restrict the evaluation of expression internally and the result is not printed in
output console. This operator is always post fixed to transcripts. The syntax is
✞
1 (%i1) <transcript> $
✆
For example
✞
1 (%i1) matrix([1,2],[3,4])$
✆
will be evaluated internally and there is no output in console. Remember that
this symbol must not followed by any string or digits or comments.
1.1.6 Do Not Execute Function (’)
If a function is prefixed with (’) then function is not executed. It just returns
the argument.
✞
1 (%i1) ’integrate(x,x)
✆
The output is
(%o1)
Z
x dx
and function without prefix with (’)
✞
1 (%i2) integrate(x,x)
✆
21. 1.1. MATHEMATICAL 21
The output is
(%o2)
x2
2
1.1.7 Re-evaluation of Specific Input (“)
The double single quote (“) provides re-evaluation of specific input once again.
For example, to evaluate the first input (%i1) once again as fourth input (%i4),
use syntax like
✞
1 (%i4) ’’%i1
✆
Example is
✞
1 (%i2) integrate(x, x);
(%i3) integrate(x^2, x);
3 (%i4) integrate(x^3, x);
(%i5) ’’%i2
✆
The output is
(%o2)
x2
2
(%o3)
x3
3
(%o4)
x4
4
(%o5)
x2
2
1.1.8 Variable Assigning Operator (:)
It assign a value to a variable.
✞
(%i4) a:2
✆
It sets ‘2’ to variable ‘a’.
1.1.9 Operator Assigner (::)
:: is similar to the : but it differs to : by evaluation method. : evaluates only
left hand side but :: evaluates left hand side as well as right hand side.
22. 22 CHAPTER 1. MAXIMA CORE
✞
1 (%i4) y:[a,b,c];%initializing operators
(%i5) y::[10,11,12];%initializing values
3 (%i6) a;%call operator ’a’
✆
✞
(%o4) 10
✆
1.1.10 Macro Function Definition Operator (::=)
::= defines a function which quotes its arguments, and the expression which it
returns is evaluated in the context from which the macro was called.
✞
1 (%i4) g(x) ::= x/99;
(%i5) g(9999);
✆
✞
(%o5) 101
✆
1.1.11 Function Operator (:=)
:= is used to initialize a function. := never evaluates the function body. The
syntax for function operator is like
✞
1 (%i4) <function name>(<independent variable>):=<function body>
✆
For example
✞
1 (%i4) f(x):=sin(x)
✆
(%o4) f(x) := sin(x)
To call the function use following syntax.
✞
1 (%i4) f(<independent variable value>)
✆
If user defined function body consists in-build functions then result is just sym-
bolic otherwise it gives numeric result. For example
✞
1 (%i4) f(x):=sin(x);
(%i5) f(10);
✆
(%o5) sin(10)
To get the numerical result rather than symbolic result then the syntax becomes
like
23. 1.1. MATHEMATICAL 23
✞
(%i4) f(x):=sin(x);
2 (%i5) ev(f(10),numer);
✆
✞
(%o5) -0.54402111088937
✆
define is also used to define a function. Its syntax is
✞
1 (%i4) define(<user define function>, <function body>);
✆
1.1.12 Sum Operator (+)
It is arithmetic additive symbol. It is used to add two or more variables. If
variables are previously assigned the values then variables are replaced by their
corresponding values and resultant sum is printed in output otherwise symbolic
addition is obtained at output. It performs algebraic sum operation. It is
commutative operator and can be used in an array. Maxima sorts operands
before applying ‘+’ operator. Among ‘+’, ‘-’, ‘/’ and ‘*’, it has third highest
priority during arithmetic calculations. Scope of operator must be specified by
using parenthesis brackets.
✞
1 (%i4) 10+11
✆
✞
(%o4) 21
✆
Another example is
✞
1 (%i4) a:10;
(%i5) a+b
✆
(%o5) b + 10
1.1.13 Subtraction Operator (-)
It is arithmetic subtraction symbol. It is used to subtract two or more variables.
If variables are previously assigned values then variables are replaced by their
corresponding values and resultant subtraction is printed in output otherwise
symbolic subtraction is obtained at output. It performs algebraic subtraction
operation. It is not a commutative operator. Among ‘+’, ‘-’, ‘/’ and ‘*’, it has
fourth highest priority during arithmetic calculations. Scope of operator must
be specified by using parenthesis brackets.
✞
(%i4) 10-11
✆
24. 24 CHAPTER 1. MAXIMA CORE
(%o4) − 1
Another example is
✞
1 (%i4) a:10;
(%i5) a-b
✆
(%o5) − b + 10
1.1.14 Product Operator (*)
It is arithmetic multiplicative symbol. It is used to multiply two or more vari-
ables. If variables are previously assigned with values then variables are replaced
by their corresponding values and resultant multiplication is printed in output
otherwise symbolic multiplication is obtained at output. It is commutative op-
erator and can be used in an array. Maxima sorts operands before applying ‘*’
operator. Among ‘+’, ‘-’, ‘/’ and ‘*’, it has second highest priority during arith-
metic calculations. Scope of operator must be specified by using parenthesis
brackets.
✞
(%i4) 10*11
✆
(%o4) 110
Another example is
✞
1 (%i4) a:10;
(%i5) a*b
✆
(%o5) 10 b
1.1.15 Division Operator (/)
It is arithmetic division symbol. It is used to divide two variables. If variables
are previously assigned with values then variables are replaced by their corre-
sponding values and resultant division is printed in output otherwise symbolic
division is obtained at output. It is not a commutative operator. Among ‘+’,
25. 1.1. MATHEMATICAL 25
‘-’, ‘/’ and ‘*’, it has highest priority during arithmetic calculations. Scope of
operator must be specified by using parenthesis brackets.
✞
(%i4) 100/10
✆
(%o4) 10
Another example is
✞
1 (%i4) a:10;
(%i5) a/b
✆
(%o5)
10
b
1.1.16 Exponential Operator (ˆ)
It is arithmetic exponential symbol. It is used to raise the power by a number
over the base value. It is binary and non-commutative operator. Grouping of
terms is required to limit the scope of the operator otherwise its scope is limited
to the succeeding terms only. If base and exponent are symbols then symbolic
output is obtained and if base and exponent are assigned numerical value then
variables are replaced by their corresponding numerical values.
✞
(%i4) 10^2
✆
(%o4) 100
Another example is
✞
1 (%i4) 10^(2^2);
✆
(%o4) 10000
✞
1 (%i5) a^b;
✆
(%o5) ab
26. 26 CHAPTER 1. MAXIMA CORE
1.1.17 Equal Operator (=)
= denotes an equation. It also represents to the equal boolean operator. In
algebraic equations, equal sign indicates that left hand side is equal to the right
hand side for specific values of independent variable. For example
2x + 3y = 10
If we choose x = 2 and y = 2 then left hand side of above equation is equal to
the right hand side of the equation. Symbolically, if a = b then values a and b
are equal.
1.1.18 Less Than Operator (<)
It is mathematical operator that tells whether the left hand side is lesser than
the right hand side term.
✞
1 (%i4) is(a < b);
✆
✞
(%o4) unknown
✆
If terms are purely number then answer is either “true’ or ‘false’.
✞
1 (%i4) is(1 < 2);
✆
✞
(%o4) true
✆
1.1.19 Grater Than Operator (>)
It is mathematical operator that tells whether the left hand side is greater than
the right hand side term.
✞
1 (%i4) is(a > b);
✆
✞
(%o4) unknown
✆
If terms are purely number then answer is either “true’ or ‘false’.
✞
1 (%i4) is(1 > 2);
✆
✞
(%o4) false
✆
27. 1.1. MATHEMATICAL 27
1.1.20 Less Than or Equals To Operator (<=)
It is mathematical operator that tells whether the left hand side is lesser than
or equals to the right hand side term.
✞
1 (%i4) is(a <= b);
✆
✞
(%o4) unknown
✆
If terms are purely number then answer is either “true’ or ‘false’.
✞
1 (%i4) is(1 <= 2);
✆
✞
(%o4) true
✆
1.1.21 Greater Than or Equals To Operator (>=)
It is mathematical operator that tells whether the left hand side is greater than
or equals to the right hand side term.
✞
1 (%i4) is(a >= b);
✆
✞
(%o4) unknown
✆
If terms are purely number then answer is either “true’ or ‘false’.
✞
1 (%i4) is(1 >= 2);
✆
✞
(%o4) false
✆
1.1.22 Lisp Name (?)
The function name which is prefixed by ‘?’ signifies that the name is a Lisp
name, not a Maxima name.
1.1.23 A List ([ ... ])
[ ... ] represents the beginning and end of a list or vector.
✞
1 (%i4) y:[a,b,c];%initializing operators as a list
(%i5) y::[10,11,12];%initializing values as a list
3 (%i6) a;%call operator ’a’ from operator list
✆
✞
(%o4) 10
✆
28. 28 CHAPTER 1. MAXIMA CORE
1.1.24 Call Last Garbage (%)
Symbolic computation, tends to create a good deal of garbage (temporary or
intermediate results that are eventually not used), and effective handling of it
can be crucial to successful completion of some programs. Symbol % is used for
calling last garbage.
✞
1 (%i1) x^2+2$
(%i2) x^2-2$
3 (%i3) solve(%); % calling last garbage
✆
(%o3) [x = −
√
2 x =
√
2]
If % is suffixed by garbage handle like ‘i1’, ‘i2’ or ‘o1’, ‘o2’ etc then specific
garbage can be called.
✞
1 (%i1) x^2+2$
(%i2) x^2-2$
3 (%i3) solve(%i1); % calling first garbage
✆
(%o3) [x = −
√
2i, x =
√
2i]
1.1.25 Previous Statement (%%)
In compound statements, namely block, lambda, or (s1, ..., sn), %% is the value
of the previous statement.
1.1.26 Exponential (%e)
It represents to the exponential base. The series expansion of ‘%e’ is
ex
= 1 +
x
1!
+
x2
2!
+
x3
3!
+ . . .
If x = 1 then above series becomes
e = 1 +
1
1!
+
1
2!
+
1
3!
+ . . .
The numerical value of ‘%e’ lies between 2 < %e < 3 and actually it is ap-
proximately equals to ‘2.718281828459045’. Remember whenever you need to
substitute ‘%e’ with its numerical value, set ‘%enumer’ to true by using the
following syntax
✞
1 (%i1) %enumer:true;
✆
29. 1.1. MATHEMATICAL 29
1.1.27 %e to numlog
When %e to numlog is ‘true’, r some rational number, and x some expression,
%e(r log x)
will be simplified into xr
.
y = er log x
Taking logarithm both side with natural base
loge y = loge er log x
or
loge y = log xr
Taking antilogarithm
y = xr
It should be noted that the radcan command also does the same transformation,
and more complicated transformations of this as well. The logcontract command
“contracts” expressions containing logarithms. By default it is ‘false’.
1.1.28 Negative Exponent as a Quotient (%edispflag)
When %edispflag is ‘true’, Maxima displays %e to a negative exponent as a
quotient. For example, %e−x
is displayed as 1/%ex
. By default it is ‘false’.
1.1.29 Demoivre Mode (%emode)
If %emode is ‘true’ then Demoivre relation enπi
is solved by using relation
eix
= cos(x) + i sin(x)
Remember that ‘n’ must be a whole integer. ‘i’ represents to imaginary constant.
For example
✞
1 (%i1) %e^(5*%i*%pi)
✆
✞
(%o1) -1
✆
1.1.30 Exponential Numerical (%enumer)
It controls that whether ‘%e’ is to be used in output or its numerical value. If
%enumer is ‘false’, ‘%e’ is used other wise its numerical value 2.718281828459045
is placed.
30. 30 CHAPTER 1. MAXIMA CORE
1.1.31 Gamma Constant (%gamma)
It is an Euler-Mascheroni constant. Its numerical value is 0.5772156649015329.
It is defined as the limiting difference between the harmonic series and the
natural logarithm
γ = lim
n→∞
n
X
k=1
1
k
− ln(n)
!
=
Z ∞
1
1
⌊x⌋
−
1
x
dx
Here, ⌊x⌋ represents the floor function.
1.1.32 Pi Value (%pi)
%pi represents to the exponential value and symbolically it is equal to π. Nu-
merical value of π is 3.141592653589793 approximately.
✞
1 (%i1) numer:true;
(%i2) %pi;
✆
✞
(%o1) 3.141592653589793
✆
1.1.33 Previous Output (%th)
%th returns the value of previous output expression identified by a number from
the current output. If there are total n outputs in the current session then mth
previous output is the (n − m)th
output from the begining of session. Syntax
for this function is
✞
1 (%i1) %th(integer)
✆
1.1.34 Most Recent Expression ( )
is the most recent input expression.
✞
1 (%i1) sin(%pi/2)$
(%i2) :lisp $_;
✆
✞
(%o2) ((%SIN) ((MQUOTIENT) $%PI 2))
✆
1.1.35 Display String (disp)
It displays only the value of the arguments rather than equations. This is useful
for complicated arguments which don’t have names or where only the value of
the argument is of interest and not the name. Remember that those inputs
which are only variables are post-fixed by symbol $. It instructs to Maxima to
31. 1.2. ERRORS 31
accept the input as key-value like arguments rather than execute it and show
output. The key-value syntax may be in form of ‘key=value’ or ‘key:value’. If
disp executed successfully, “done” is returns as output by Maxima.
✞
1 (%i1) b[1,2]:x-x^2$
(%i2) x:123$
3 (%i3) disp(x, b[1,2], sin(1.0));
✆
✞
123
x-x^2
0.8414709848078965
(%o3) done
✆
1.2 Errors
1.2.1 Error (error)
The variable error is set to a list describing the error. The first element of error
is a format string, which merges all the strings among the arguments supplied
to error function and the remaining elements are the values of any non-string
arguments. Syntax for error function is
✞
(%i1) error(expr_1, ..., expr_n)
✆
1.2.2 Error Size (error size)
error size modifies error messages according to the size of expressions which
appear in them. If the size of an expression (as determined by the Lisp func-
tion ERROR-SIZE) is greater than error size, the expression is replaced in the
message by a symbol, and the symbol is assigned the expression. The symbols
are taken from the list error syms. The default value of error size is ‘10’.
1.2.3 Error Symbol (error syms)
In error messages, expressions larger than error size are replaced by symbols,
and the symbols are set to the expressions. The symbols are taken from the
list error syms. The first too-large expression is replaced by error syms[1], the
second by error syms[2], and so on.
1.2.4 Error Message (errormsg)
Reprints the most recent error message. The variable error holds the message,
and errormsg formats and prints it.
32. 32 CHAPTER 1. MAXIMA CORE
1.2.5 Debug Mode Maxima (debugmode)
By default, Maxima does not debugs to any errors and mistakes. To set the
debug mode true use debugmode function like
✞
1 (%i4) debugmode(true)
✆
It returns ‘true’ if debug mode is set to true otherwise returns false.
1.2.6 Show Examples (example)
It returns the method for using a function whose name is supplied as an argu-
ment. To see all the listed functions for function example use it like
✞
1 (%i1) example();
✆
To see the example of nroots use it like
✞
1 (%i1) example(nroots);
✆
It returns the method of use of function nroots. At the end of successful execu-
tion of example function, “done” is printed in output console.
1.2.7 Set Numerical Precision (fpprec)
fpprec is used to set the decimal places of decimal numbers ie precision of nu-
merical output. The syntax is
✞
1 (%i1) fpprec : integer for decimal places;
✆
For example
✞
1 (%i1) fpprec : 16
✆
Now the outputs will have sixteen decimal places. If we want to get result upto
five decimal places then set precision to five like
✞
1 (%i1) fpprec : 5
✆
1.2.8 Toggle to Floating Point (numer)
By defalut numer is ‘false’ and the symbols are used in calculations of expression.
If numer is ‘true’ then variables or symbols in expression which have numerical
values are replaced by their values. The syntax is used like
✞
1 (%i1) numer:true % for setting true value
(%i2) numer:false % for setting false value
✆
For example
33. 1.3. PROCEDURAL 33
✞
(%i1) numer:true;
2 (%i2) %e
✆
✞
(%o2) 2.718281828459045
✆
If numer is set to ‘false’ then result is symbolic.
✞
1 (%i1) numer:false;
(%i2) %e
✆
✞
(%o2) %e
✆
1.3 Procedural
1.3.1 Interrupt Maxima (kill)
It removes all bindings (value, function, array, or rule) from the arguments. An
argument may be a symbol or a single array element. The syntax is
✞
1 (%i1) kill(symbol)
(%i2) kill([array element 1, array element 2, ...)
3 (%i3) kill(labels)
(%i4) kill(integers)
5 (%i5) kill(all)%kills all values, function, array or rules
✆
1.3.2 Modes of Variables (mode declare)
mode declare is used to declare the modes of variables and functions for subse-
quent translation or compilation of functions. mode declare is typically placed
at the beginning of definition of a function, at the beginning of a Maxima script,
or executed at the interactive prompt. The syntax used is
✞
1 (%i1) mode_declare ([y_1, y_2, ...], fixnum)%Or
✆
or
✞
1 (%i2) mode_declare (y_1, mode_1, ... y_n, mode_n])
✆
The ‘fixnum’ are “float”, “bignum” etc. For example,
✞
1 (%i1) F(x):=(mode_declare([x], float), x+2.0)
✆
This converts independent variable x as floating value and as well as function
F(x) = x + 2.0 into floating function.
34. 34 CHAPTER 1. MAXIMA CORE
1.3.3 Evaluate Print Expression (print)
print evaluates and displays expressions one after another, from left to right,
starting at the left edge of the console display. The syntax for the function print
is
✞
1 (%i1) print(expr 1, expr 2, ...., expr n)
✆
✞
1 (%i1) print((a+b)^2, (a-b)^2)
✆
(%o3) b2
− 2 a b + a2
1.3.4 Labels (labels)
labels returns the list of either input or output or intermediate expression labels
which begin with symbol. Typically symbol is the value of either inchar or
outchar or linechar. Syntax for the function is
✞
1 (%i1) labels(symbol)
✆
1.3.5 Line Number (linenum)
It is the line number of the current pair of input and output expressions.
1.3.6 List of Options (myoptions)
myoptions is the list of all options ever reset by the user, whether or not they
get reset to their default value.
1.3.7 Ordinary Base (obase)
obase may be assigned any integer between 2 and 36 (decimal), inclusive. The
default value of obase variable is decimal ‘10’. Other bases are binary ‘2’, octal
‘8’, hexadecimal ‘16’ and ‘32’.
✞
1 (%i1) obase:2$
(%i2) 99;
✆
✞
(%o2) 1100011
✆
35. 1.3. PROCEDURAL 35
1.3.8 Print the Reset Option (optionset)
When optionset is ‘true’, Maxima print outs a message whenever a Maxima
option is reset. This is useful if the user is doubtful of the spelling of some
option and wants to make sure that the variable he assigned a value to was
truly an option variable. The default value is ‘false’.
1.3.9 Play Previous Garbage (playback)
It prints the previously collected garbage by the Maxima. The syntax is
✞
1 (%i1) playback ([inputs, outputs], grind, time, slow)
✆
Argument “slow” is useful in conjunction with save or stringout when creating a
secondary-storage file in order to pick out useful expressions. Argument “time”
displays the computation time for each expression. Argument “grind” displays
input expressions in the same format as the “grind”. Output expressions are
not affected by the “grind” option.
1.3.10 Prompting Symbol (prompt)
prompt is the prompt symbol of the demo function, playback (slow) mode and
the Maxima break loop. The default value is ‘ ’.
1.3.11 Quit the Session (quit)
quit terminates the current Maxima session. It is used like quit().
1.3.12 Rationalized Print (ratprint)
When ratprint is true, a message informing the user about the conversion of
floating point numbers into rational numbers is displayed. The default value is
‘true’.
1.3.13 Enter into Lisp System (to lisp)
to lisp variable let to enter into Lisp system of Maxima. It enables to initiated
new variable, function etc in Maxima that can be used later in Maxima after
returning to Maxima. To return to Maxima,
✞
1 (%i1) to_maxima;
✆
variable is used (including parenthesis brackets).
36. 36 CHAPTER 1. MAXIMA CORE
1.3.14 Call Functions of Current Session (backtrace)
backtrace function is used to call the all functions of current session. The length
of tracing is controled by supplying an integer value as argument to the function.
The syntax used is
✞
1 (%i1) backtrace(length of trace as integer)
✆
1.3.15 Break Maxima Evaluation (break)
This function has syntax like
✞
1 (%i1) break(expr 1, expr 2, ..., expr n)
✆
break evaluates and prints ‘expr 1’ to ‘expr n’ and then causes a Maxima break
at which point the user can examine and change his environment. Upon typing
“exit”; the computation resumes.
1.3.16 Bug Reporting Info (bug report)
It returns the details of Maxima and the link where a bug can be reported.
1.3.17 Build Information (build info)
build info returns the information consisting date, time, building plateform,
Lisp compiler, version of Maxima and host etc used during the compilation and
building of Maxima.
1.3.18 Debug Mode (debugmode)
By default debugmode is false. When a Maxima error occurs, Maxima will start
the debugger if debugmode is ‘true’. The user may enter commands to examine
the call stack, set breakpoints, step through Maxima code, and so on. Enabling
debugmode will not catch Lisp errors.
1.3.19 Show Evaluation Time (showtime)
showtime is ‘true’ then time taken by maxima to evaluate the transcript is shown
at the output. By default it is ‘false’. This variable is useful to check the speed
of execusion of function and provide the ways of script cleaning.
1.3.20 Evaluation Time (time)
time returns the time taken durign the evaluation by Maxima. The handle is
supplied as argument to get the time taken by Maxima in evaluation of specific
function. time can only be applied to output line variables; for any other vari-
ables, time returns unknown. Set showtime as ‘true’ to make Maxima print out
the computation time and elapsed time with each output line.
37. 1.3. PROCEDURAL 37
✞
1 (%i1) integrate(x,x)
(%i2) time(%o1);
✆
✞
(%o2) [0.0]
✆
1.3.21 Promp Read (read)
read first prints the statement and then ask for one input in the console. The
expression entered in the console is read by Maxima and returns the evaluated
result of the expression in the console. The expression entered into the console
muste be terminated by dollar sign(‘$’).
✞
1 (%i1) a=10;
(%i2) f:read(Enter new value)$
3 Enter new value 2^a$
(%i3) f;
✆
✞
(%o3) 1024
✆
1.3.22 testsuite files
Similar to the run testsuite to check the test pass of a file.
✞
1 (%i1) testsuite_files();
✆
1.3.23 Test The Maxim (run testsuite)
run testsuite tests producing the desired answer are considered “passes” as are
tests that do not produce the desired answer, but are marked as known bugs.
✞
1 (%i1) run_testsuite();
✆
1.3.24 Read Function Without Evaluation (readonly)
If readonlyfunction is used in place of readfunction with similar syntax, then it
returns the expression to console without evaluation.
✞
1 (%i1) a=10;
(%i2) f:readonly(Enter new value)$
3 Enter new value 2^a$
(%i3) f;
✆
(
38. 38 CHAPTER 1. MAXIMA CORE
1.3.25 Activate Contexts (activate)
It activates the contexts. The facts in these contexts are then available to make
deductions and retrieve information. The facts in these contexts are not listed
by facts. Syntax for activate is
✞
(%i1) activate(context 1, context 2, ...)
✆
1.3.26 List of Activated Contexts (activecontexts)
activecontexts is a list of the contexts which are active by way of the activate
they are subcontexts of the current context.
1.3.27 Additive Function (additive)
Function declare, if used as the syntax given below, tells Maxima to recognize
a function as a additive function. The syntax for this is
✞
1 (%i1) declare(f, additive)
✆
1.3.28 Alternative Name for Function (alias)
It assigns an alternative name to Maxima function. Syntax for this function is
✞
1 (%i1) alias(new fcn name 1, old fcn name 1, ...)
✆
1.3.29 Declare String as Alphabic (alphabetic)
Function declare, if used as the syntax given below, tells Maxima to recognize
all characters in the ‘s’ as alphabatic characters. The syntax for this flag is
✞
1 (%i1) declare(s, alphabatic)
✆
1.3.30 Arguments In Expression (args)
It returns the number of arguments in an expression. Syntax used is
✞
1 (%i1) args(expression)
✆
1.3.31 Atomic Expression (atom)
If the function is used like
✞
1 (%i1) atom(expression)
✆
39. 1.3. PROCEDURAL 39
and Maxima returns ‘true’ then ‘expression’ is atomic (i.e. a number, name or
string) otherwise ‘expression’ is non atomic. Thus
✞
1 (%i1) atom(5)
✆
is true while
✞
1 (%i1) atom(a[1])
✆
and
✞
1 (%i2) atom(sin(x))
✆
are ‘false’ (assuming a[1] and x are unbound).
1.3.32 Declare a Function Antisymmetric (antisymmet-
ric)
Function declare, if used as the syntax given below, tells Maxima to recognize
a function as an antisymmetric function. The syntax for this flag is
✞
1 (%i1) declare(f, antisymmetric)
✆
Here function ‘f’ will assumed as an antisymmetric function.
1.3.33 Check The Integer Type (askinteger)
✞
1 (%i1) askinteger(expression, integer type)
✆
attempts to determine from the assume database whether expression is an in-
teger or not. There are three categories of ‘integer type’ - (i) “odd”, (ii) “even”
and (iii) “integer”.
1.3.34 Retrive User Property (get)
✞
1 (%i1) get(a, i)
✆
It retrieves the user property indicated by i associated with atom a or returns
‘false’ if a doesn’t have property i.
1.3.35 Declare Variable as Integer (integer)
Function declare, if used as the syntax given below, tells Maxima to recognize
a variable as an integer. The syntax for this flag is
✞
1 (%i1) declare(var, integer)
✆
Here variable ‘var’ will assumed as an integer.
40. 40 CHAPTER 1. MAXIMA CORE
1.3.36 Declare Variable as Non-Integer (noninteger)
Function declare, if used as the syntax given below, tells Maxima to recognize
a variable as a noninteger. The syntax for this flag is
✞
1 (%i1) declare(var, noninteger)
✆
Here variable ‘var’ will assumed as a noninteger.
1.3.37 Integer Variabe (integervalued)
Function declare, if used as the syntax given below, tells Maxima to recognize
a function as an integervalued function. The syntax for this flag is
✞
1 (%i1) declare(f, integervalued)
✆
Here function ‘f’ will assumed as an integervalued function.
1.3.38 Query for Sign of Expression (asksign)
asksign attempts to deduce the sign of expressions from the sign of operands
within the expression. For example, if a and b are both positive, then a + b is
also positive.
✞
1 (%i1) asksign(1-2)
✆
✞
(%o1) neg
✆
1.3.39 Declare Variables (assume)
It adds predicates to the current context. If a predicate is inconsistent or redun-
dant with the predicates in the current context, it is not added to the context.
The context accumulates predicates from each call to assume. Syntax for the
function assume is
✞
1 (%i1) assume(var condition var values, .....)
✆
‘conditions’ are the mathematical comparision symbols like ‘=’, ‘=’, ‘’, ‘’
and ‘=’ etc. For example
✞
1 (%i1) assume(x1,y1)$
(%i2) is(xy)
✆
✞
(%o2) true
✆
41. 1.3. PROCEDURAL 41
1.3.40 Declare Variable as Positive (assume pos)
When assume pos is ‘true’ and the sign of a parameter x cannot be determined
from the current context or other considerations, sign and asksign (x) return
‘true’. By default it is ‘false’.
1.3.41 Declare As Communative Function (commutative)
Function declare, if used as the syntax given below, tells the simplifier that
function is a commutative function. The syntax for this is
✞
1 (%i1) declare(f, commutative)
✆
1.3.42 Compare Expression (compare)
It returns the comparative result according to the comparative relation between
two supplied arguments to the function compare. Syntax for this function is
✞
1 (%i1) compare(expr 1, expr 2)
✆
If Maxima is unable to compare then it returns “unknown”.
1.3.43 Context (context)
context names the collection of facts maintained by assume, forget. Binding con-
text to a name ‘foo’ changes the current context to ‘foo’. If the specified context
‘foo’ does not yet exist, it is created automatically by a call to newcontext. The
specified context is activated automatically. By default it is “initial”.
1.3.44 Contexts (contexts)
contexts is a list of the contexts which currently exist, including the currently
active context. By default its value is [“initial”, “global”].
1.3.45 Deactivate Context (deactivate)
deactivate deactivates the contexts supplied to the function as its arguments.
✞
1 (%i1) deactivate(context 1, context 2, .....)
✆
1.3.46 Delcaration Statement (declare)
It assigns the atom or list of atoms the property or list of properties respectively.
It is used like
✞
1 (%i1) declare(atom, property)
✆
42. 42 CHAPTER 1. MAXIMA CORE
1.4 Declarations
1.4.1 Declare As Decreasing Function (decreasing)
Function declare, if used as the syntax given below, tells Maxima to recognize
a function as a decreasing function. The syntax for this is
✞
1 (%i1) declare(f, decreasing)
✆
1.4.2 Declare As Increasing Function (increasing)
Function declare, if used as the syntax given below, tells Maxima to recognize
a function as a increasing function. The syntax for this is
✞
1 (%i1) declare(f, increasing)
✆
1.4.3 Declare Variable as Even Variable (even)
Function declare, if used as the syntax given below, tells Maxima to recognize
a symbol as a even integer variable. The syntax for this is
✞
1 (%i1) declare(sym, even)
✆
1.4.4 Declare Variable as Odd Variable (odd)
Function declare, if used as the syntax given below, tells Maxima to recognize
a symbol as a odd integer variable. The syntax for this is
✞
1 (%i1) declare(sym, odd)
✆
1.4.5 Variable As a Constant (constant)
Function declare, if used as the syntax given below, tells Maxima to recognize
a symbol as a constant. The syntax for this is
✞
1 (%i1) declare(sym, constant)
✆
1.4.6 Check a Constant (constantp)
It returns ‘true’ if an expression is a constant expression, otherwise returns
‘false’.
✞
1 (%i1) constantp(expression)
✆
43. 1.4. DECLARATIONS 43
1.4.7 Get Features (featurep)
It attempts to determine whether the object has the feature on the basis of the
facts in the current database. If so, it returns ‘true’, else ‘false’.
✞
1 (%i1) featurep(object name, feature name)
✆
1.4.8 Set Feature (features)
Maxima recognizes certain mathematical properties of functions and variables.
These are called ”features”. The syntax
✞
1 (%i1) declare(x, foo)
✆
gives the property foo to the function or variable x. The declare function used
like
✞
1 (%i1) declare(feature name, feature)
✆
declares a new feature. features is a list of mathematical features.
1.4.9 Status (is)
is asks whether the predicate expression is provable from the facts in the as-
sume database. If predicted expression is provable, it returns ‘true’ otherwise it
returns ‘false’.
✞
1 (%i1) 12$ % it is true as 1 is always less than 2.
(%i2) is(12) % ask the prediction, result is true
✆
✞
(%o2) true
✆
1.4.10 Kill Contextx (killcontext)
It kills the contenxt from the Maxima. Syntax is
✞
1 (%i1) killcontext(context 1, ...)
✆
1.4.11 Simplify as Left-Associative (lassociative)
Function declare, if used as the syntax given below, tells to simplifier that the
function is a left-associative. The syntax for this is
✞
1 (%i1) declare(expr, lassociative)
✆
44. 44 CHAPTER 1. MAXIMA CORE
1.4.12 Recognize Function as N-Array (nary)
Function declare, if used as the syntax given below, tells Maxima to recognize
a function as n-array function. The syntax for this is
✞
1 (%i1) declare(f, nary)
✆
1.4.13 Maximum Negative Expansion (maxnegex)
maxnegex is the largest negative exponent which will be expanded by the expand
command. By default its value is ‘1000’.
1.4.14 Match Declaration (matchdeclare)
Associates a predicate with a variable so that variable matches expressions for
which the predicate returns anything other than false. Syntax is
✞
1 (%i1) matchdeclare(var, predicate)
✆
1.4.15 Simplify as Multiplicative (multiplicative)
Function declare, if used as the syntax given below, tells Maxima to expand an
expression as a multiplicative. The syntax for this is
✞
1 (%i1) declare(expr, multiplicative)
✆
1.4.16 Multiply Two Expression (multthru)
This function multiply two or more expressions with each other. multthru does
not expand exponentiated sums if present in the expressions. This function is
the fastest way to distribute products (commutative or noncommutative) over
sums.
✞
1 (%i1) multthru(expr 1, expr 2)
✆
1.4.17 Negative Distribution (negdistrib)
If this variable is set to ‘true’ this negative coefficient of an expression is dis-
tributed to the all terms of the expression. By default it is ‘true’.
✞
1 (%i1) -(a+b)
✆
(%o1) − b − a
Now, setting negdistrib as ‘false’.
45. 1.4. DECLARATIONS 45
✞
1 (%i1) negdistrib:false$
(%i2) -(a+b)
✆
(%o2) − (b + a)
1.4.18 Create New Context (newcontext)
It creates a new contenxt in the Maxima. Syntax is
✞
(%i1) newcontext(context)
✆
1.4.19 Numerical Value of Variable (numerval)
It declares that a variable have numerical value.
✞
1 (%i1) numerval(var 1, num 1, ....., var n, num n)
✆
1.4.20 Pull Out Constant Term (outative)
Function declare, if used as the syntax given below, tells Maxima to pull out
the constant term from the expression as coefficient. The syntax for this is
✞
1 (%i1) declare(f, outative)
✆
1.4.21 Positive Function (posfun)
Function declare, if used as the syntax given below, tells Maxima to recognize
a function f to be a positive function.
✞
1 (%i1) is (f(x) 0)
✆
yields ‘true’.
✞
1 (%i1) declare(f, posfun)
✆
1.4.22 Properties of Atom (properties)
Returns a list of the names of all the properties associated with the atom. It is
used like
✞
1 (%i1) properties(atom name)
✆
46. 46 CHAPTER 1. MAXIMA CORE
1.4.23 Assign a Value to Property (put)
put assigns value to the property (specified by indicator) of atom. ‘indicator’
may be the name of any property, not just a system-defined property. The
syntax used is
✞
1 (%i1) put(atom, value, indicator)
✆
1.4.24 Simplify as Right-Associative (rassociative)
Function declare, if used as the syntax given below, tells to simplifier that the
function is a a right-associative. The syntax for this is
✞
1 (%i1) declare(expr, rassociative)
✆
1.4.25 Declare Variable as Irrational Variable (irrational)
Function declare, if used as the syntax given below, tells Maxima to recognize
a variable as an irrational variable. The syntax for this flag is
✞
1 (%i1) declare(var, irrational)
✆
Here variable ‘var’ will assumed as an irrational variable.
1.4.26 Declare Variable as Irrational Variable (rational)
Function declare, if used as the syntax given below, tells Maxima to recognize
a variable as a rational variable. The syntax for this flag is
✞
1 (%i1) declare(var, rational)
✆
Here variable ‘var’ will assumed as a rational variable.
1.4.27 Declare Variable as Complex Variable (complex)
Function declare, if used as the syntax given below, tells Maxima to recognize
a variable as a complex variable. The syntax for this flag is
✞
1 (%i1) declare(var, complex)
✆
Here variable ‘var’ will assumed as a complex variable.
1.4.28 Declare Variable as Imaginary Variable (imaginary)
Function declare, if used as the syntax given below, tells Maxima to recognize
a variable as an imaginary variable. The syntax for this flag is
✞
1 (%i1) declare(var, imaginary)
✆
Here variable ‘var’ will assumed as an imaginary variable.
47. 1.4. DECLARATIONS 47
1.4.29 Declare Variable as Real Variable (real)
Function declare, if used as the syntax given below, tells Maxima to recognize
a variable as a real variable The syntax for this flag is
✞
1 (%i1) declare(var, real)
✆
Here variable ‘var’ will assumed as a real variable.
1.4.30 Remove Indicator From Atom (rem)
The syntax for the rem is
✞
1 (%i1) rem(atom, indicator)
✆
It removes the property indicated by ‘indicator’ from ‘atom’. rem reverses the
effect of put. rem returns done if atom had an indicator property when rem was
called, or ‘false’ if it had no such property.
1.4.31 Remove Property (remove)
It removes the properties from the atom. It has syntax like
✞
1 (%i1) rem(atom vector, property vector)
✆
If “all’ is used as argument in place of ‘atom vector’ then ‘property vector’ will
be removed from all atoms.
1.4.32 Scalar Value (scalar)
Function declare, if used as the syntax given below, tells Maxima to recognize
a variable as a scalar variable. The syntax for this flag is
✞
1 (%i1) declare(var, scalar)
✆
Here variable ‘var’ will assumed as a scalar variable.
1.4.33 Sign of Expression (sign)
sign attempts to deduce the sign of expressions from the sign of operands within
the expression. For example, if a and b are both positive, then a + b is also
positive.
✞
1 (%i1) sign(1-2)
✆
✞
(%o1) neg
✆
48. 48 CHAPTER 1. MAXIMA CORE
1.4.34 Declare Variable as Symetric Function (symmetric)
Function declare, if used as the syntax given below, tells Maxima to recognize
a function as a symmetric function. The syntax for this flag is
✞
1 (%i1) declare(f, symmetric)
✆
Here function ‘f’ will assumed as a symmetric function.
49. Chapter 2
Numeric Evaluation
2.1 Number Theory
2.1.1 Big Float (bffac)
bffac is acronym of “Bigfloat” version of the factorial function. The syntax for
the function is
✞
1 (%i1) bffac(expression, integer)
✆
The second argument ‘integer’ is how many digits to retain and return, it’s a
good idea to request a couple of extra.
2.1.2 Big Float Zeta Function (bfhzeta)
bfhzeta returns the Hurwitz zeta function for the arguments s and h. The return
value is a big float (bfloat); n is the number of digits in the return value. The
Hurwitz zeta function is defined as
zeta(s, h) =
∞
X
n=0
1
(n + h)s
To use this function, “bffac” should be loaded at first. The syntax for this
function is
✞
1 (%i1) bfhzeta(expr s, expr h, num of return digit n)
✆
2.1.3 Convert to Big Float (bfloat)
It converts all numbers and functions of numbers in expression to bigfloat num-
bers. The number of significant digits in the resulting bigfloats is specified by
the global variable fpprec.
✞
1 (%i1) bfloat(expression)
✆
49
50. 50 CHAPTER 2. NUMERIC EVALUATION
2.1.4 Is Big Float (bfloatp)
Returns ‘true’ if expression is a bigfloat number, otherwise ‘false’.
✞
1 (%i1) bfloatp(expression)
✆
2.1.5 Digamma Big Float Function (bfpsi) (bfpsi0)
bfpsi is the polygamma function of real argument z and integer order n. bfpsi0
is the digamma function. The syntax is
✞
1 (%i1) bfpsi0 (z, fpprec)
✆
or
✞
1 (%i1) bfpsi (0, z, fpprec)
✆
These functions are same and return bigfloat values. fpprec is the bigfloat
precision of the return value.
2.1.6 Big Float to Rational Number (bftorat)
bftorat controls the conversion of bfloats to rational numbers. When bftorat
is ‘false’, ratepsilon conversion take place. When bftorat is ‘true’, generated
rational number generated will accurately represent the bfloat. By default it is
‘false’.
2.1.7 Truncate Big Float (bftrunc)
bftrunc causes trailing zeroes in non-zero bigfloat numbers not to be displayed.
Thus, if bftrunc is ‘false’, bfloat(1) displays as 1.000000000000000B0. Otherwise,
this is displayed as 1.0B0. By default it is ‘true’.
2.1.8 Big Float Zeta Function (bfzeta)
It returns the Riemann zeta function for the argument s. The return value is a
big float (bfloat); n is the number of digits in the return value. The syntax is
✞
1 (%i1) bfzeta(s, n)
✆
2.1.9 Complex Big Float (cbffac)
It returns complex big float and needs to load bffac. The syntax is
✞
1 (%i1) cbffac(complex number, precision points)
✆
51. 2.1. NUMBER THEORY 51
2.1.10 Floating Point (float)
It converts integers, rational numbers and bigfloats in expression to floating
point numbers.
2.1.11 Float to Big Float (float2bf)
When float2bf is ‘false’, a warning message is printed when a floating point
number is converted into a bigfloat number. By default it is ‘true’.
2.1.12 Is Floating Number (floatnump)
It returns ‘true’ if expression is a floating point number, otherwise ‘false’. The
syntax is
✞
1 (%i1) floatnump(expression)
✆
2.1.13 Float Point Precision (fpprec)
fpprec is the number of significant digits for arithmetic on bigfloat numbers.
fpprec does not affect computations on ordinary floating point numbers. By
default its value is ‘16’. It is used like
✞
1 (%i1) fpprec:integer less than 16
✆
2.1.14 Float Point Print Precission (fpprintprec)
fpprintprec is the number of digits to print when printing an ordinary float or
bigfloat number. For ordinary floating point numbers, when fpprintprec has a
value between ‘2’ and ‘16’ (inclusive), the number of digits printed is equal to
fpprintprec. Otherwise, fpprintprec is ‘0’, or greater than ‘16’, and the number
of digits printed is ‘16’. By default its value is ‘0’.
✞
1 (%i1) fpprintprec:integer 2 to 16 0
✆
2.1.15 Keep Float Points (keepfloat)
By default it is ‘false’. When keepfloat is ‘true’, prevents floating point numbers
from being rationalized when expressions which contain them are converted to
canonical rational expression (CRE) form.
2.1.16 Numerical Solution (numer)
numer causes some mathematical functions (including exponentiation) with nu-
merical arguments to be evaluated in floating point. It causes variables in ex-
pression which have been given numerals to be replaced by their values. It also
sets the float.
52. 52 CHAPTER 2. NUMERIC EVALUATION
2.1.17 Numerical Power of Negative Integer (numer pbranch)
By default, this variable is ‘false’. The option variable numer pbranch controls
the numerical evaluation of the power of a negative integer, rational, or floating
point number. When numer pbranch is ‘true’ and the exponent is a floating
point number or the option variable numer the numerical result returns us-
ing the principal branch, otherwise a simplified, but not an evaluated result is
returned.
✞
1 (%i1) (-2)^0.75;
✆
✞
(%o1) (-2)^0.75
✆
✞
1 (%i2) (-2)^0.75,numer_pbranch:true;
✆
✞
(%o2) 1.189207115002721*%i-1.189207115002721
✆
2.1.18 Number to Variables (numerval)
This function assigns the numerical values to the variables. Syntax used like
✞
1 (%i1) numerval (var_1, val_1, ..., var_n, val_n)
✆
2.1.19 Tolerance in Floating Point (ratepsilon)
ratepsilon is the tolerance used in the conversion of floating point numbers
to rational numbers, when the option variable bftorat. By default its value is
2.0e−15
.
2.1.20 Rationalize (rationalize)
Convert all double floats and big floats in the Maxima expression to their exact
rational equivalents. If you are not familiar with the binary representation of
floating point numbers, you might be surprised that
✞
1 (%i1) rationalize (0.1)
✆
does not equal 1/10. This behavior isn’t special to Maxima. The number 1/10
is a repeating, not a terminating, binary representation.
✞
1 (%i1) rationalize(0.1)
✆
The output is
(%o1)
3602879701896397
36028797018963968
53. 2.1. NUMBER THEORY 53
2.1.21 Is Rational Number (ratnump)
Returns ‘true’ if expression is a literal integer or ratio of literal integers, other-
wise ‘false’.
2.1.22 Print Message Rational (ratprint)
When ratprint is ‘true’, a message informing the user of the conversion of floating
point numbers to rational numbers is displayed. By default it is ‘true’.
2.1.23 Numerical Status (stats numer)
If stats numer is ‘true’, inference statistical functions return their results in
floating point numbers. If it is ‘false’, results are given in symbolic and rational
format.
55. Chapter 3
Conditions
Following conditions can be used in Maxima.
3.1 Linear
3.1.1 If Statement (if)
if is a conditional statement. The syntax for function if is like
✞
1 (%i2) if condition
then
3 body if condition true
else
5 body if condition false
✆
✞
1 (%i2) f(x) := if x=1 then (x+1)$
(%i2) f(3)
✆
(%o1) false
The output is false as x 6= 1. Again
✞
(%i2) f(x) : = if x=1 then (x+1)$
2 (%i2) f(1)
✆
(%o1) 2
55
56. 56 CHAPTER 3. CONDITIONS
3.1.2 If-Else Statement (if-else)
if-else is a conditional statement where function body for ‘true’ and ‘false’ con-
ditions are given and only ‘true’ case is printed in output. Syntax for if-else
condition is
✞
(%i2) if condition
2 then
body if condition true
4 else
body if condition false
✆
✞
1 (%i2) f(x) : = if x=1 then (x+1) else (x-1)$
(%i2) f(3)
✆
(%o1) 2
3.2 Loop
3.2.1 For Statement (for)
It is loop operator. The syntax for for loop is
✞
(%i1) for initial var
2 thru
bounding limit
4 step
integer
6 do
function body;
✆
For example
✞
1 (%i1) for i:1 thru 10 step 3 do print(2*i);
✆
✞
2
8
14
20
(%o1) done
✆
while statement can be applied with for function.
✞
1 (%i1) for i: 1 while i = 10 do s: s+i;
✆
✞
(%o1) 55
✆
57. 3.2. LOOP 57
3.2.2 Do Statement (do)
The do statement is used for performing iteration.
✞
1 (%i1) for i: 1 while i = 10 do s: s+i;
✆
✞
(%o1) 55
✆
3.2.3 While Statement (while)
It allow the iteration to be performed until the require condition is satisfied.
Generally while statement comes with do statement.
✞
1 (%i1) for i: 1 while i = 10 do s: s+i;
✆
✞
(%o1) 55
✆
59. Chapter 4
Arithmetic
Arithmetical functions are followings.
4.1 Arithmatic Functions
4.1.1 Absolute Number (abs)
abs returns the absolute value of an supplied number. If x = 1.20152 then its
absolute value is 1.201. Similarly if x = −1.20152, then its absolute value is
1.201.
✞
1 (%i1) abs(1.20152);
✆
✞
(%o1) 1.201
✆
✞
1 (%i1) abs(-1.20152);
✆
✞
(%o1) 1.201
✆
4.1.2 Summation of Terms (sum)
sum is used for sum evaluation of a series. Syntax for sum is
✞
1 (%i1) sum(expression, variable, initial value, final value)
✆
Summation
n
X
i=1
i2
is expanded as
n
X
i=1
i2
= 12
+ 22
+ 32
+ . . . + n2
59
60. 60 CHAPTER 4. ARITHMETIC
If either initial or final value is symbol, then output is just symbolic representa-
tion of summation. The sum of a series of square of first ‘n’ integers is evaluated
as
✞
1 (%i1) sum(x^2, x, a, b)
✆
The output is
(%o1)
b
X
x=a
x2
If initial final values are integers then
✞
1 (%i1) sum(x^2,x,1,10)
✆
The output is
✞
(%o1) 385
✆
4.1.3 Numerical Summation of Terms (nusum)
nusum is used for numerical sum evaluation of a series. Syntax for nusum is
✞
1 (%i1) nusum(expression, variable, initial value, final value)
✆
The numerical sum of a series of square of first ‘n’ integers is evaluated as
✞
1 (%i1) nusum(x^2,x,1,n)
✆
The output is
(%o1)
n (n + 1) (2 n + 1)
6
This output is in symbolic form.
4.1.4 Numerical Factor of Algebraic Fraction (numfactor)
It returns the numerical factor from an algrebraic fraction.
✞
1 (%i1) numfactor(15/8 * %e);
✆
The output is
(%o1)
15
8
61. 4.1. ARITHMATIC FUNCTIONS 61
4.1.5 Product of Terms (product)
product is used for product evaluation of a series. Syntax for product is
✞
1 (%i1) product(expression, variable, initial value, final value)
✆
Product
n
Y
i=1
i2
is expanded as
n
Y
i=1
i2
= 12
× 22
× 32
× . . . × n2
If either initial or final value is symbol, then output is just symbolic representa-
tion of product. The product of a series of square of first ‘n’ integers is evaluated
as
✞
1 (%i1) product(x^2, x, a, b)
✆
The output is
(%o1)
b
Y
x=a
x2
If initial final values are integers then
✞
1 (%i1) product(x^2, x, 1, 5)
✆
✞
(%o1) 14400
✆
4.1.6 Maximum Value (max)
max returns the maximum value of supplied arguments as vector or matrix.
✞
1 (%i1) max(20,15,47,85,0,-2)
✆
✞
(%o1) 85
✆
4.1.7 Minimum Value (min)
min returns the minimum value of supplied arguments as vector or matrix.
✞
1 (%i1) min(20,15,47,85,0,-2)
✆
✞
(%o1) -2
✆
62. 62 CHAPTER 4. ARITHMETIC
4.1.8 Modulo (mod)
It returns the modulo of two expressions as shown in the syntax of this function.
✞
1 (%i1) mod(expression 1, expression 2)
✆
Modulo between two pure integer values is given by
✞
1 (%i1) mod(10,3)
✆
✞
(%o1) 1
✆
Modulo for algebraic relations
✞
1 (%i1) mod(a^3-b^3,a-b);
✆
(
4.1.9 Square Root (sqrt)
It returns the square root of given number.
✞
1 (%i1) numer:true;
(%i2) sqrt(10)
✆
✞
(%o2) 3.16227766016838
✆
4.1.10 Sorting Elements (sort)
4.1.11 Simplification Environment (simp)
When simp is used as an evflag with a value ‘false’, the simplification is sup-
pressed only during the evaluation phase of an expression. The flag can not
suppress the simplification which follows the evaluation phase. The simplifi-
cation is switched off globally. The expression sin(1.0) is not simplified to its
numerical value. The simp-flag switches the simplification on is
✞
1 (%i4) simp:true;
✆
✞
(%o4) true
✆
✞
1 (%i5) x:sin(1.0),simp:false;
✆
✞
(%o5) 0.8414709848078965
✆
63. Chapter 5
Algebra
This section includes the functions can be used in algebra.
5.1 Linear Equations
5.1.1 Algebraic Evaluation (algebraic)
By default algebraic is ‘false’. It must be set ‘true’ in order to simplify the
algebraic numbers.
5.1.2 Solving Linear Equation (solve)
A linear equation can be solved by using solve function. An algebraic equation,
f(x) = 0 of a variable x, would be arranged in form of f(x) = 0 before getting
the roots of the equation. If equation is in form of f(x) = a then it should be
arranged as f(x) − a = 0 before supplying it as argument to the solve function.
The synopsis of the solve function is
✞
1 (%i1) solve([linear algebraic equation],[variable])
✆
Example is
✞
1 (%i1) solve([x^2-x+1=0],[x])
✆
The output is
(%o1)
x = −
√
3 i − 1
2
, x =
√
3 i + 1
2
#
If we have to solve more than one function then syntax for solve becomes
✞
1 (%i11) x+y=1
✆
63
64. 64 CHAPTER 5. ALGEBRA
(%o11) x + y = 1
✞
1 (%i12) x-y=2
✆
(%o12) x − y = 2
✞
1 (%i13) solve([%o11,%o12])
✆
(%o12)
y = −
1
2
, x =
3
2
5.1.3 Simplify Logs, Exponent Radicals (radcan)
radcan simplifies expressions, which contain logs, exponentials and radicals. For
a somewhat larger class of expressions, radcan produces a regular form. Two
equivalent expressions in this class do not necessarily have the same appearance,
but their difference can be simplified by radcan to zero. For example
log(x + x2
) − log(x)
a
[log(1 + x)]
a/2
= [log(x + 1)]
a/2
Maxima code is
✞
1 (%i3) radcan((log(x+x^2)-log(x))^a/log(1+x)^(a/2));
✆
(%o3) log (x + 1)
a
2
5.1.4 Radical Expansion (radexpand)
By default it is ‘true’. It controls the expansion of radicals. When it is ‘true’
for all, factors are pulled outside to the radicals. For example, when radexpand
is ‘true’,
√
4x2 becomes 2x as a coefficient of the expression.
5.1.5 Rational Simplification (ratsimp)
It is abbrevation of “rational simplification”. It simplifies the expression and all
of its subexpressions, including the arguments to non-rational functions. The
65. 5.1. LINEAR EQUATIONS 65
result is returned as the quotient of two polynomials in a recursive form. The
syntax used is
✞
1 (%i3) ratsimp(expression, arg 1, arg 2, ... , arg n)
✆
For example
✞
1 (%i3) sin(x)/x + exp((1+log(x))^2 - log(x));
✆
(%o3)
sin (x)
x
+
e(log(x)+1)2
x
✞
1 (%i3) sin(x)/x + exp((1+log(x))^2 - log(x));
(%i4) ratsimp(%);
✆
(%o4)
sin (x) + x2
elog(x)2
+1
x
5.1.6 Rationalized Simplification Flag (ratsimpexpons)
By default it is ‘false’. When ratsimpexpons is true, ratsimp is applied to the
exponents of expressions during simplification.
5.1.7 Evaluation of Expression in Environment (ev)
It evals an expression in the environment as specified by the user in form of
arg1, arg2, . . ., argn. In all of these arguments, at least one must be from the
environments simp, noeval, diff, integrate, expand, detout, derivlist, float, numer,
pred, eval or other valid function names. The syntax used for this function is
✞
(%i3) ev(expression, arg 1, arg 2, ... , arg n)
✆
A function f(x) = x2
+2, is to be derivated with respect to independent variable
‘x’ by using the ev function is
✞
1 (%i3) x+1;
(%i4) ev(%,1);
✆
(%o4) 2
66. 66 CHAPTER 5. ALGEBRA
5.1.8 Evaluation of Expression (eval)
It is used as an argument in the function ev to cause an extra evaluation of
expression or relation.
5.1.9 Expansion of Algebraic Relations (expand)
expand expands to the algebraic relations consisiting product of sum of two
or more independent variables. Exponents of sum of two or more variables or
algebraic constants are splited in simplified terms and numerical constants are
made corresponding coefficients of their respective terms. The syntax used is
✞
(%i3) expand(expression)
✆
For example
✞
1 (%i3) (a+b)^2;
(%i4) expand(%);
✆
(%o4) b2
+ 2ab + a2
Another form of the syntax of expand is
✞
(%i3) expand(expression, mpnum, maximum power of denominator)
✆
Here ‘mpnum’ limits the expansion of those terms whose exponent is less than or
equal to ‘mpnum’ in the numerator. Similarly ‘mpden’ limits the expansion of
those terms whose exponent is less than or equal to ‘mpden’ in the denominator.
This limitation is applicable when power of exponents is positive. It is helpful
to expand the specific radicals in the rational algebraic expression. For example
✞
1 (%i3) (a+b)^2;
(%i4) expand(%, 1);
✆
Does not exapanded as the exponent of numerator is ‘2’ that is greater than
the ‘mpnum’ value ‘1’. Remember if there is negative exponents of a radical
value in rational expressions then their power is made positive by changing their
position from the numerator to denominator and vice versa.
5.2 Inequality Polynomial
5.2.1 Equality (equal)
equal compares two expressions, whether two expressions are equal or not. The
stat of comparison is returned when it is asked by using function is. It is used
for true state. If the condition is ‘true’, then the function is proven by facts and
assumed in database.
67. 5.2. INEQUALITY POLYNOMIAL 67
✞
(%i3) equal(x, x^2);
2 (%i4) is(%);
✆
(%o4) unknown
✞
(%i3) equal(x*x,x^2);
2 (%i4) is(%);
✆
(%o4) true
5.2.2 Inequality (notequal)
notequal compares two expressions, whether two expressions are equal or not.
The stat of comparison is returned when it is asked by using function is. It is
used for false state.
✞
(%i3) notqual(x, x^2);
2 (%i4) is(%);
✆
(%o4) unknown
✞
(%i3) notequal(x*x,x^2);
2 (%i4) is(%);
✆
(%o4) false
5.2.3 Solve Algebraic Polynomials (algsys)
algsys used to solve the simultaneous polynomial equations for the list of the
variables. All the polynomial equations and list of variables to be supplied as
arguments to the function must be in vector form. The syntax used is
✞
(%i3) algsys([s^3+1], [s]);
✆
68. 68 CHAPTER 5. ALGEBRA
(%o3)
s = −1
s =
√
3 i + 1
2
s = −
√
3 i − 1
2
5.2.4 Solve Linear Equations (linsolve)
linsolve is used to solve the simultaneous linear equations for the list of variables.
The expressions must be polynomials in the variables and may be equations.
All the linear equations and list of variables to be supplied as arguments to the
function must be in vector form. The syntax used is
✞
1 (%i3) linsolve([2*x+8*y-4*z=10, 2*x+y+4*z=8, x-8*y-z=-20], [x, y, z]);
✆
(%o3) x = −
45
89
y =
198
89
z =
151
89
5.2.5 Check The Stat Of Database (is)
is attempts to determine whether the predicate expression is provable from the
facts in the assume database. If the proven state from the facts is not assumed
then it returns the status ‘unknown’.
✞
1 (%i3) notequal(x*x, x^2);
(%i4) is(%);
✆
(%o4) false
5.2.6 Check The Stat Of Database (maybe)
maybe similar to is, attempts to determine whether the predicate expression
is provable from the facts in the assume database. If state is not assumed in
database, it returns ‘unknown’ result.
✞
(%i3) notequal(x, x^2);
2 (%i4) maybe(%);
✆
69. 5.2. INEQUALITY POLYNOMIAL 69
(%o4) unknown
✞
(%i5) notequal(x*x, x^2);
2 (%i6) maybe(%);
✆
(%o6) false
5.2.7 Algebraic Substitution (subst)
This function substitutes old variable by new variable. The syntax for this
function is
✞
(%i3) subst(new var, old var, expression);
✆
For example
✞
1 (%i5) subst(y, x, x^n-a^n);
✆
(%o6) yn
− an