Here are some examples of Sage used as a Computer algebra system.

Define the symbols x and y using `var`

. Then define r2 in terms of x and y as per the Pythagorean theorem.

1 2 3 |
sage: x, y = var('x, y') sage: r2 = x * x + y * y sage: r2 |

The output remains in terms of x and y:

1 |
x^2 + y^2 |

This works with trigonometry…

1 2 3 4 5 |
sage: r = sqrt(r2) sage: sin0 = y/r sage: cos0 = x/r sage: theta = atan(sin0/cos0) sage: tan(theta) |

Output:

1 |
y/x |

…and matrices too. Below is an example of a matrix to translate and rotate a point in two dimensions.

1 2 3 4 5 6 7 8 |
sage: dx, dy, r = var('dx, dy, r') sage: s = sin(r) sage: c = cos(r) sage: tx = matrix([[c, s, dx], ....: [-s, c, dy], ....: [0, 0, 1]]) sage: v = vector([x, y, 1]) sage: tx * v |

Output:

1 |
(x*cos(r) + y*sin(r) + dx, y*cos(r) - x*sin(r) + dy, 1) |

Sage also does differentiation and integration but I am still trying to wrap my head around those two concepts.