# An introduction to Axiom (2): Algebra

This is the second in a sequence of posts about the open source CAS Axiom. The first can be found at http://amca01.wordpress.com/2008/05/25/an-introduction-to-axiom-1/

Axiom variables are created using the “colon equals” method of many other computer languages, and user defined functions with a double equals:

Note that for the last example, the expression involving radicals can be simplified directly, but it requires playing around with types.

Expansion, factorization and simplification of all sorts of expressions can be accomplished easily:

Axiom has powerful algorithms to solve polynomial equations, systems of polynomials, and linear system. There are in fact several different solve functions:

solve
Basic solve function: will produce real solutions. The precision of the solution can be adjusted by including an extra parameter
complexSolve
The complex version of solve – will produce complex solutions, also with an adjustable numerical precision
As its name implies, solutions in the form of radicals, if such can be found.

Note that solve will in general produce numeric solutions, unless the equations are linear. When the precision is given, the list of variables need not be given explicitly, as, according to the documentation: “The list of variables would be redundant information since there can be no parameters for the numerical solver.”

## 8 thoughts on “An introduction to Axiom (2): Algebra”

1. Zach says:

Alasdair,

First of all, as a new Axiom user, thank you and I look forward to the future (more advanced) posts.

In your examples, you seem to use solve to find numerical solutions, but in reality, as (32) shows, solve can produce symbolic solutions. But:

solve (p(x) = 0, x)
==> [x^3 – 6x – 6=0]

does not work, assumedly because the one real root can only be expressed in terms of radicals. This seems weird to me. Coming from Maxima, there is no barrier between moving to radical solutions, is there a reason for this barrier in Axiom?

In fact the expression above returns p(x) = 0. I thought that Axiom returns “failed” when it cannot perform the task at hand.

Another question, in expressions like 28, 29, and 31, you do not tell what variables to solve in terms of. Does Axiom just attempt to do so with every free variable in the expression? A assume that p(x) is expanded before solve and friends gets its hands on it, so we cannot pull out the argument list there.

Anyway, thanks,
Zach

2. Vassilios A. Zoukos says:

Please check the following example of simplify()
A := sin(2*x)/(2*sin(x)*cos(x))
sin(2x)
(10) ————-
2cos(x)sin(x)
Type: Expression Integer
simplify(A)

sin(2x)
(11) ————-
2cos(x)sin(x)
Type: Expression Integer
In this case mathematical simplification gives 1 (!)
Any idea to get a working simplification? (Thanks for your courses)

3. amca01 says:

For simplifying A, you need to give Axiom a little help; try writing the expression in complex exponential form:

simplify(complexElementary(A))

This should produce 1.

4. demian says:

Hi, I’m trying to solve a system of 3 trigonometric equations in 9 variables. I’ve hit a snag and I’m hoping someone will be able to tell me what I’m doing wrong. Here’s what I’ve done:

Input:

eqn1:=equation one
eqn2:=equation two
eqn3:=equation three
solve([eqn1=0,eqn2=0,eqn3=0],[var1,var2,var3])

Output:

(0)
Type: List(List(Equation(Expression(Integer))))

5. Daniel Carrera says:

Are you using some axiom front-end? How do you get the nice-looking output in this post? I only know of the command-line version of axiom, so all the square roots and fractions are done with ASCII art, which is very ugly.

1. amca01 says:

I think I used Axiom with Texmacs (http://www.texmacs.org/) which includes a plugin for Axiom, allowing nice looking input and output as you see in these posts.