Get Introduced to Algebra with Maxima
Maxima is a computer algebra system derived from the earlier Macsyma which in turn, was written in Lisp. This article, the 14th in the series on the mathematical journey through open source, introduces us to algebra, using Maxima.
The algebraic capability of Maxima is what sets it apart. We have worked through basic shell math, bench calculator bc, and finally, the ultra capable Octave. But none of these systems could do algebra with symbols, also referred to as symbolic or analytic mathematics. Let’s walk through a few examples to demonstrate what this means.
Getting started
The Maxima command line can be started in the shell by typing maxima. The -q option suppresses the initial welcome message. Typing quit(); on the maxima command line quits Maxima. Typical Maxima commands are terminated either with a semicolon (;) or a dollar ($) - the latter suppressing any print from the command. Outputs are numbered and prefaced by %o. Inputs are also numbered, and prefaced by %i. Here are a few factorisation examples: $ maxima -q (%i1) factor(x^3 - 1); (%o1) (x2 - 1) (x + x + 1) (%i2) factor((x + 1)^4);
(%o2) (x4 + 1) (%i3) expand(%o2);
(%o3) x4 + 4x3 + 6x2 + 4x + 1 (%i4) factor(6!);
(%o4) (%i5) expand(6!); (%o5) (%i6) quit();
24 32 5
720
factor() and expand() are two complementary functions while doing factorisation and simplification, respectively. Note the way the powers in the output are printed. For example, 6! is factorised as 24 * 32 * 5. In case you want the output on a single line, you can use the command string(), which we shall use from now on. Also, note the use of output labels as inputs to the commands, namely expand(%o2) in the above example.
Integration and differentiation
Octave has enabled you to do integration and differentiation, but more of definite integrals and differences. Yes, it has indefinite operations for polynomials. But with Maxima, you can just plug in the expressions, as you usually do in your math notebooks. This is what it means: $ maxima -q (%i1) integrate(cos(x),x); (%o1) sin(x) (%i2) diff(cos(x),x); (%o2) - sin(x) (%i3) string(integrate(1/(a^2 + x^2)^(3/2),x)); (%o3) x/(a^2*sqrt(x^2+a^2)) (%i4) string(diff(log(x), x)); (%o4) 1/x (%i5) y: (x+1)^2$ /* $ suppresses the output */ (%i6) string(diff(y, x)); (%o6) 2*(x+1) (%i7) string(integrate(y, x)); (%o7) x^3/3+x^2+x (%i8) quit();
Variable assignments can be done in Maxima using the colon (:), as shown in the input %i5, above. From there onwards, the variable can be used instead of the original expression, as shown in the inputs %i6 and %i7. Note that the variable assignment assigns the complete symbolic expression, unlike the usual value assignments.
Solving equations
Whether it is a linear set of equations, polynomial equations or, for that matter, non-linear equations, Maxima can solve most of them with ease, and even that, in an analytical way. Here are a few common examples: 1) The two solutions of a quadratic equation; 2) Two simultaneous equations in two variables; 3) A non-linear equation with irrational number e. A demonstration of the Maxima code follows: $ maxima -q (%i1) string(solve(a*x^2 + b*x + c = 0, x)); (%o1) [x = -(sqrt(b^2-4*a*c)+b)/(2*a),x = (sqrt(b^2-4*a*c)-b)/ (2*a)] (%i2) string(solve([a*x + b*y = c,d*x + e*y = f],[x, y])); (%o2) [[x = -(c*e-b*f)/(b*d-a*e),y = (c*d-a*f)/(b*da*e)]] (%i3) string(solve([exp(x) + 1/exp(x) = a],[x])); (%o3) [x = log(a/2-sqrt(a^2-4)/2),x = log(sqrt(a^24)/2+a/2)] (%i8) quit();
For ages, equation solving has been one of the most fascinating as well as challenging tasks while solving mathematical problems. So, when the computer is there to aid us, we do try to go beyond human limitations. We have just seen the well-known formula for the two solutions of a quadratic equation. How about the same for a cubic equation? It looks really complicated and, hence, we typically don’t use it. But, if you still want to see it, here it is:
source operating system like Ubuntu running on a machine available for retail is a fantastic thing to see. It is excellent because it helps people recognise it. Kudos to them and I wish them success. This will create awareness about open source technology, overall.
Q Does Fedora have any similar plans? Fedora doesn’t actually go and engage with vendors in that sense. So if someone wants to take Fedora and bundle it into the hardware that they sell, we are fine with that.
Q Can you share your insights on what the contribution of Indian developers is to the Fedora project? Actually, we do have a significant number of developers in India. A lot of the work they do has to do with language support, like that of the Indian languages. We have people who contribute in terms of testing, and contributors who do work related to virtualisation. Most of them are Red Hat employees. Interestingly, this is how Red Hat hires. Most of the people we bring on board are because of their involvement in the community. That is a sure shot way of validating your skill set. So, even if a person is doing some localisation in the various Indian languages in Fedora, chances are that we may end up hiring him to continue to do the job that he has been doing anyway.
“If you look at the Fedora mailing list, you will find a lot of discussions, counter points and arguments on ways that things can be done in the project. A bulk of those commenting there are community people, who look at Fedora as their own project and there is a sense of personal ownership in the project as well.”
Q What does Red Hat do to increase the involvement of developers in the Fedora project? FUDCON is one of the main events that we use for the Fedora community. There is another event called the Fedora Activity Day, which comprises smaller Fedora conferences that are done over one day, mostly in the universities and institutes of higher learning, where there is a hackathon or a similar event relating to usage of technology. We have seen very good participation from the community in these events. There are a lot of other activities going on in different parts of India, like those in the IITs and other engineering colleges.