Doing Math
Arithmetic
Basic arithmetic operations are easy to enter in Mathematica. You may use your choice of notation, and you may choose to enter symbols via the palettes or the keyboard.
| Keystrokes | Input | Output | Comments |
|---|---|---|---|
| 4, ,+, ,4 3,-,1,6 |
4+4 3-16 |
8 -13 |
Addition, subtraction. Spaces are optional. |
| 4,*,4 4, ,4 4,4 4,Esc,*,Esc,4 |
4*4 4 4 44 4 |
16 16 44 16 |
Multiplication. A space can mean multiplication as well... ...but you should be careful. You can also use the symbol. |
| 3,/,4 3,Esc,d,i,v,Esc,4 3,Ctl-/,4 |
3/4 3 |
Exact division. | |
| 3,^,5 3,Ctl-^,5 |
3^5 35 |
243 243 |
The text version The symbolic version |
| 3,^,(,1,/,2,) Ctl-@,3 N,[,Ctl-@,3,Ctl-Space,] |
3^(1/2) N[ |
1.73205 |
An approximation. |
| %,Ctl-^,2 | %2 | 3. | Square last output. |
Mathematica's data restrictions are as follows:
- Integers can be of any size, up to your computer's memory.
- Real and complex operations are carried out with arbitrary (limitless) precision, up to your computer's memory, unless N is used.
- See Help->Help Browser: Numerical Computation->Numerical Precision->N, and section 1.4.9 of The Mathematica Book.
| |
| If you want to use double precision, you must explicitly say so. See above. |
Algebra
Mathematica is more than a calculator, of course. We will now try out some of Mathematica's Computer Algebra System (CAS) features.
| Keystrokes | Input | Output | Comments |
|---|---|---|---|
| a | a | a | All names are symbols. |
| a,=,4 | a=4 | 4 | Defining a constant. |
| Esc,a,l,p,h,a,Esc,=,3 | 3 | Greek letters (see palettes). | |
| (,x,+,1,),Ctl-^,2 | (x+1)2 | (x+1)2 | An expression. |
| E,x,p,a,n,d,[,%,] | Expand[%] | 1+2x+x2 | Algebraic expansion.... |
| S,i,m,p,l,i,f,y,[,%,] | Simplify[%] | (x+1)2 | ...and simplification. |
From this point onward, we will assume that you know how to enter keystrokes.
| Input | Output | Comments |
|---|---|---|
| p=x3+3x2+3x+1 | x3+3x2+3x+1 | p is now an alias for the expression. This is not mathematical equality. |
| Solve[p==0] | {{x->-1}, {x->-1}, {x->-1}} |
Solve the equation p==0. Mathematica returns a set of transformation rules. The system has three identical solutions. |
| p /. x->2 | 27 | Substitute 2 for x (temporarily). |
| p==0 /. x->2 | False | 27 does not equal 0. |
| Transformation rules are like the subs command in Maple. | |
| Go exploring in the Algebra Palette: File->Palettes->AlgebraicManipulation. |
Previous:Orientation



