A brief list of the most important commands in YACAS, with examples

YACAS (Yet Another Computer Algebra System) is, as suggested by its name, a computer algebra system. Essentially, a CAS is a computer program that allows you to go algebra calculations on a computer, saving time and effort by not having to go through those calculations by hand.

Yacas (I'll use this mostly-lowercase spelling convention from this point forward) is, in my humble opinion, the most impressive major CAS currently available. It's free and open-source, which sets it apart from arguably more powerful but also much more expensive professional titles like Mathematica and Maple. It also uses a text-based console interface, setting it apart from several other free competitors that go for the GUI or require extensive additional libraries to run; Yacas just downloads and runs without a lot of additional fanfare. Yacas also easily and quickly works out trigonometry functions, calculus derivatives and integrals, and linear algebra computations with simple, intuitive commands; it even has a fair set of logic functions and its own little programming-language-like syntax, allowing you to automate math functions on a larger scale. All this from a program that's very small (in terms of computer bytes), making it a quick download that's easy to get started with.

Yacas' official website is located at:

yacas.sourceforge.net

Besides offering Yacas for download, the website also has extensive documentation on the commands available in Yacas; however, the documentation is in several pieces and can be somewhat overwhelming for those who just want to do basic math, so I ended up creating this very quick list of the most important math commands in Yacas, along with examples of how to use them. You can get much more information at the program's own website, but if you just want to quickly see an example of how to get a derivative or a cosine, this page might be faster. Actual command examples are rendered using the <PRE> tag for that awesome computer-console-text look.

Note that most Yacas commands and functions are case-sensitive, so you generally need to use the expected capitalization.

First things first: To quit Yacas, just type quit on a line by itself.

You can use Yacas to solve simple (or complicated) arithmetic problems using simple numbers:

2 + 2
100 * 2
5 - 3
2 * 5
20 / 5

However, Yacas does not use the standard practice of assuming multiplication if there is no operator between entities, so typing something like "3y" will produce an error; you will need to use "3*y" instead.

Yacas supports exponentiation:

2^8
10^8

Yacas understands parentheses. The following two lines yield different results:

(10 / 2) + 3
10 / (2 + 3)

Yacas knows about "Pi" as a constant. It's case-sensitive (the P must be capitalized).

Yacas understands I as the imaginary unit (the square root of -1).

Yacas also understands "Infinity". For example:

2^Infinity

Oddly enough, however, Yacas does *NOT* contain e (the base of the natural logarithm) as a constant. However, you can use e by making use of the Exp() function. This function calculates e raised to the power of its argument; for example, the following calculates e^2:

Exp(2)

Based on this, you can use Exp(1) to represent e. Or, better yet, you can simply use the following line to define your own e, and then just use "e" in the future:

Set(e,Exp(1))

Yacas supports trigonometric functions. As with some other types of packaged math functions, Yacas offers both "symbolic" and "numerical" trig functions. What's the difference? Well, you use the "numerical" functions when you actually want to see the number that results from the function, while you use the "symbolic" functions to simply represent the operation, without needing to see the numerical result. Symbolic results are displayed if they can be shown easily, but this often isn't the case. For example, typing the following line:

Sin(Pi)

...Will yield a 0. (In Yacas, trig functions use radians.) However, typing in the following will simply echo back what you typed:

Sin(3)

In many computations, you just want to represent the sine of 3, without actually needing to see 0.14112... In such a case, you'd use Sin, which is the symbolic sine function. If you want to actually see the number, use MathSin instead, like this:

MathSin(3)

Similarly, Yacas has Cos, Tan, ArcSin, ArcCos, and ArcTan functions. These are all symbolic, and have MathCos, MathTan, MathArcSin, MathArcCos, and MathArcTan numerical equivalents.

However, it might be worth noting here how you can tell Yacas to force a numerical answer if possible. To order Yacas to output its result, as best as possible, as an actual decimal number, you need to use the N() function. You can type this to view the actual result of Sin(3):

N(Sin(3))

Yacas has square root functions. Sqrt() is symbolic, while MathSqrt() is numerical. The following shows 4 because the result is easy to display:

Sqrt(16)

...But for numbers with ugly square roots, if you actually want to see the root, you'll need to use MathSqrt:

MathSqrt(3)

The Abs function returns the absolute value of something. Both of the following lines give the same results

3
Abs(-3)

Yacas can tell you whether a number is prime or not. (It will display "True" if the number is prime, and "False" if the number is not prime.) Use the IsPrime() function:

IsPrime(2)
IsPrime(10)

Yacas can understand non-numeric variables in expressions, and will auto-simplify expressions on the fly. Typing in the following will simply display "x":

x * y / y

Sometimes, however, Yacas may not give as simple an answer as possible. If you want to tell it to try and simplify something as much as possible, use the Simplify() function:

Simplify(x)

Yacas, like a programming language, lets you set variables to equal certain numbers. For example, most of the time, typing "x" will simply display "x", since that's all Yacas knows about x and it cannot be simplified further. However, if you type the following:

Set(x,3)

...Then from that point on, you can use x to represent 3. Similarly, you can set variables to equal more complex evaluations or functions.

Yacas can evaluate limits (which are the beginnings of calculus). The syntax is:

Limit(var, val) expr

...Where "var" is the variable that approaches some value, "val" is the value it approaches, and "expr" is the expression whose limit you want to find as var approaches val. Let's use the following ultra-simple limit calculation as an example:

Limit(x,2) x

This line says "find the limit of x as x approaches 2". The answer, obviously, is 2. The next one is a little trickier:

Limit(x,1) 5*(x-1)/(x-1)

Producing a direct result for the expression is impossible, because it creates a divide-by-zero situation. (Note that a lot of calculus limits are used explicitly because they're intended to evaluate expressions that involve dividing by zero.) However, if you consider the expression (x-1) on its own, you'll realize that we are multiplying 5 by this value, then immediately dividing the result by this same value. Since multiplying something by any value and then immediately dividing by the same value should, in general, leave the original number unchanged, we see that even as x approaches very close to 1, the expression remains 5; the expression doesn't become undefined until x is exactly 1. Hence, the limit is 5.

Limits are cool in this way, because they allow you to evaluate things involving division by zero, but they have their limits (pun not intended). The following Yacas line will still yield "Undefined":

Limit(x,1) x/0

Moving on from limits, you can do calculus derivatives with Yacas using the D function, like this:

D(x) x*2
D(x) x^2

Doing indefinite integrals is pretty straightforward:

Integrate(x) x*2
Integrate(x) x^2
Integrate(x) x

You can add the left- and right-hand sides of a range to calculate a definite integral, as well:

Integrate (x, 1, 2) x
Integrate (x, 2, 3) x
Integrate (x, 1, 2) x*2
Integrate (x, 2, 3) x*2

Back to the main page