Maxima can operate as a calculator
where (%i1) means the first line of input and (%o1) is the first line of output..
Note that 2/3 is a fraction.c You could make if a decimal result if you made either the 2 or the 3 a decimal number
or you could use the float() command
You can compute factorials
You can raise numbers to powers using the same symbol as in Excel. To raise 2 to the second power
To raise 2 to the third power
To raise 3.3 to the one hundredth power
(%i3) (3.3)^100;(%o3) 7.1022178218665199*10^+51
You can use the power command to take square roots
and third and forth roots
or go wild and take the 100th root
If you want you can find values of the exponential function
and take the natural logarithm
One thing you will need to do is assign values to variables. For example suppose that you want to give x a value of 3.
x : 3
Note the way you do it: x : 3. That is x followed by a colon followed by a 3.
The Maxima output is
where (%i1) means the first line of input and (%o1) is the first line of output.
Suppose we assign x a value of 3 and y a value of 2 and add the two
And perform other operations on these symbols
Maxima can solve equations with two unknowns
or three unknowns
Expressions are mathematical statements assigned to labels like eqn1, eqn2, etc.
Expressions make solving equations a bit more elegant
We will make heavy use of functions in this class. A function is defined using the := symbol. Suppose you want define the function f(x)=x+3 in Maxima. The command to use is
Then the value of f(x) at x=10 is
and if x=3.3
You can define two functions and solve for the value of x that makes them equal
Then you can evaluate the functions to see if the solution is correct
and it looks like Maxima was successful.
It will often times be useful to assign the solution to a label. If you want to assign the solution to a label like ans (for answer) type
and now ans contains the solution of the equation. Now we can refer to the label ans
Unfortunately ans contain the string x=2/3. What we really want is the right hand side (rhs) of the expressions x=2/3. We can get the rhs of the expression using the following command
The rather mysterious command (%i8) ans:rhs(ans); means let ans have the value of the right hand side of the expression in ans. In other words ans has been given a new value equal to the right hand side of the old value of ans. The reason for the ans in the mysterious command is explained in the next section.
This is useful because now we can use ans as a numerical value
More than one solution to an equation
The command ans:rhs(ans) contains the odd seeming ans. That is because equations can have more than one solution. Consider solving x^2-1=0
Now there are two solutions for x^2-1=0, they are x=-1 and x=1. We can get these two solutions using
and just to see if we are correct, evaluate f(x) using x=1 and x=-1
Using Maxima to solve supply and demand problems.
Suppose a demand function is defined as
D(p) =100 –p
where quantity demanded will decrease as p increases. The supply function is defined to be S(p) = 2p where quantity supplied increases as p increases. Use Maxima to solve for p.
Now check to see if these solutions are correct. Note p_eq is where we store the value of the equilibrium price.
The equilibrium quantity demanded is
and the equilibrium supply is
Example 2 extends example 1 and makes it a bit more general
Let demand be
where p again is price and Y is income. are parameters that specify how demand changes if p or Y change. If p changes by one unit, then D(p) will change by units and if Y changes by one unit D(p) will change by units.
The supply relation is
where C represents the cost of producing a unit of output. Maxima can solve this model
Next we can give values to the parameters and get numerical answers to the model
Note that you can enter more than one statement on a line. If you terminate the statements with a $, the statement is not printed. The ‘rat’ statements are something Maxima puts in.
Next check to see if supply really does equal demand
Supply does equal demand so the solution is correct.
Next suppose that the cost of production increases from C=1 to C=2. This should decrease supply and raise prices.
Price did rise (from p=101/2=60.5 to p=51). The equilibrium output fell from 49.5 to 49.0.