Excercise 1
Basic arithmetic
1. Calculate 10 sin(10)
2. Divide the result by 4
3. Add 10 to the result
4. Calculate the square of the result
5. Add together the two previous results.
Substitutions
Direct substitution
1. Set the variable x equal to 10 and y equal to 5 using direct substitution
2. Set z equal to 2x+y using direct substitution. Check the value of z.
3. Set x equal to 8
5. What's the value of z now? Try it.
Clear x, y and z
Delayed substitution
1. Set x and y equal to 3 and 4.
2. Using delayed substitution, set z equal to x*y
3. Check the value of z
4. Set x equal to 5
5. What's the value of z now? Try it.
6. Clear y and check what is z.
Clear x, y and z
Truth values
1. Evaluate 10 != 11
2. Evaluate 0==0.
3. Evaluate 1<=3.
4. Evaluate 10==a.
5. Evaluate -10 < 10.
Bonus excercises
Mathematica can check the types of variables and numbers. Evaluate the following:
1. NumberQ[1.24]
2. EvenQ[4]
3. OddQ[6]
4. PrimeQ[7]
Lists
Elementarities
1. Construct the list {1,2,3,5,7,11} and set it to the variable x.
2. Add together the first and last element of x.
3. Multiply the second element with the third element and add the fourth element to the product.
Clear x.
More elementarities
1. Construct the list {a,b,c} and set it to variable x.
2. Construct the list {1,2,3} and set it to y.
3. What would x+y give? Try it.
Clear x and y
Two-dimensional lists
1. Set A equal to the list {{1,2,3}, {4,5,6}}.
2. Extract the second element of A.
3. Extract the third element of the first element of A.
4. Extract the first element of the second element of A.
5. Add together the two previous results.
Clear A.
Extra excercises
1. Construct the matrix (
) and set it to A.
a
b
c
d
e
f
2. Extract the last element of the first row of A.
3. How would you extract the element e from A?
Clear A.
Rules, equations, solving equations
First
1. Calculate
+x+1with x equal to 10
2. Calculate x+y with x and y equal to 1 and 2
3. Calculate
with a and b equal to 3 and 4
4. Set x equal to 10 using a rule and a substitution operator.
Second
1. Solve the equation
+p x+q=0, and set the result to the variable e.
2. Extract the second element of the solution list.
3. Using the above rule, calculate x+p.
4. Calculate the above with p=1and q=2.
5. Check the numerical value of the above using the function N[...].
Third
1. Set the variable Y equal to the equation
+p
+q x+r=0.
2. Solve equation Y.
3. Check the solution by substituting it into the equation and simplifying the resulting expression
Fourth
1. Set the variable y equal to 
2. Apply the functions Expand, Factor, Together, Apart, Cancel, Simplify, Numerator ja Denominator on y.
3. Solve the equation y=0by taking the numerator of y and finding its zeros.
4. Check the solution by substituting it into the equation. What do you see? How could you fix the situation?
Extra excercise
1. Solve the set of equations {
for x and y. Use the function Sqrt[] for the square root.
![]()
b x+a y=3
2. Simplify the above result
3. Set above a and b equal to 1 and 2.
4. Calculate the numerical value of the above result using the function N.
| Created by Mathematica (April 10, 2007) |