Quantcast
Channel: Dot Physics » math
Viewing all articles
Browse latest Browse all 10

Maxima can be useful

$
0
0

The other day I found myself faced with six equations that needed to be solved algebraically. Just so you know, I am a big fan of paper for most of these cases – but this was out of control. I was making silly mistakes and causing all sorts of problems. What to do? My first though was to use some symbolic plugins for python. I tried sympy and it is nice. However, it was not giving correct solutions for solving 3 equations – I don’t know if this is a bug or what.

Maxima

I think I found Maxima through Wikipedia’s Computer algebra system page. It’s free and free and runs on Mac OS X and Windows.

The point of this post is not just to tell you about this software, really it is to tell me about it. I probably won’t use this for a while, and so I will forget what I did. First, some useful resources:

So, if you want to get a good start, look at the intro link above. But I will summarize a couple of quick things. First, entering expressions. One thing I did not like about sympy was that expressions were entered as 2x + y = 0 instead of 2x = -y. In Maxima, just enter the equation. Here are some rules:

  • Use normal order of operations stuff
  • Don’t forget * for multiplication. If you do 2x, you will get an error. 2*x is ok.
  • You can use variables that are longer than 1 character, but it can’t start with a number – x2 is ok, but not the variable 2x.
  • When you enter a statement, you must end with a “;”
  • The output of every entry is labeled something like – %o19. This is nice because you can refer to this output in later entries.

An Example

Let me show a simple example. I will use two of the kinematic equations to create a third kinematic equations – algebraically. Let me start with:

i-6460ad7ff77b35f8c7dd6f76b245810f-2010-07-13_la_te_xi_t_1.jpg

Now, to enter these two equations into Maxima:

i-d59e0e062dce1643636eb348fa446ef0-2010-07-13_terminal_lisp_80x24.jpg

Notice that you use normal (non-python) format for entering expressions – by non-python I mean that the “^” means raised to the power instead of “**”. The output is formatted in a way to look a little nicer.

Now, I want to solve the second equation for t:

i-e582fb2f8e26b785c3897e95f151f203-2010-07-13_terminal_lisp_80x24_1.jpg

Here, I referred to the original equation by its output line number (%o3 in this case where that is an “o”, not a zero). Next, I just want to substitute this expression for t into the first equation.

i-7d34585b9557e58ad56ae06c91604e0d-2010-07-13_terminal_lisp_80x24_2.jpg

The command in line %i6 may look weird. But this is saying take the equation %o2 (which is the first equation) and substitute t = … (which is equation %o5). Now I want to take this equation and solve for v2 – so that it is in its usual form.

i-ea04162b27369c211605cba1f9830387-2010-07-13_terminal_lisp_80x24_3.jpg

I don’t know why it gave the expression twice. Update: As pointed out in the comments below, this is because there are two answers, a positive and a negative. End update If you just wanted 1 answer, you could type %o7[1]; – I don’t know why Maxima’s arrays don’t use the normal use of [0] being the first element.

Finally, if you want to get this as v2^2:

i-b2632b2ccc20cf8a334bd392417c514b-2010-07-13_terminal_lisp_80x24_4.jpg

That is good enough to get some useful stuff done. Also, hello to future me. I am probably going to find this post 3 months from now when I forget how to do something in Maxima.


Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>