CS 158A Assignment 1

The purpose of this exercise is to help the students to get used to typing
expressions in
Mathematica.

1. Evaluate the following expressions in Mathematica.

a) 3.5 + 5.63 * 2

3.5+5.63 2
14.76


2
b) 7.5 - 10.2 / 3.1


5 4
c) (78.123 + 24 ) - 4 (41.2 - 1120)


1 3
2. Let y = --- + --- .
9 7


Find
a) the rational result of y,


b) the numerical value of y with 20-digit precision.



3. Type FactorInteger[123456789] in Mathematica. What do you get?
What does it tell you?


4. Find
a) log 2 (of base 10) with 10-digit precision, and


b) ln 2 (of base e) with 10-digit precision.


5. Find the square root of pi with 30-digit precision.


6. Let x = 7, y = 5, and z = 3. Find


3 3
a) x - xy + y (Don't forget a space or * between x and y.)


3 3 4
b) (x - xy + y ) .


c) Compare the numerical values of

Log[z, x y] , Log[z, xy], and Log[z, x] + Log[z, y]
(Type in the three expressions in a list.)



d) Compare the numerical values of Log[z, x/y] and Log[z, x] - Log[z,

y].



7. Let x = 5, y = 3, and z = 125.
a) Type in x^2y.
What do you get? Is it the same as you expected?


b) Compare z/x^2y, z/(x^2y), and z/x^(2y). Obtain a list of these
three
values in rational forms, and make sure that you understand how each
was evaluated.


3 2
8. Let f(x, y) = (1 - y) (x + y)


Find a) f(2, 3)


b) f(1, 1 - a)


c) f(1 + x, 1 - y)

9. In each of the following exercises, you are asked whether the two logical

expressions have the same logical value (True or False):

a) (a > b) && (c>d) || (e>f), ((a > b) && (c>d)) || (e>f)

b) !(a>b)&&(c>d) , !((a>b) && (c>d)

c) (a>b) && (c>d) && (1.0 == 2.0), (a>b) && !(a>b)

Give numerical values to the variables involved and use Mathematica to
evaluate them!

10. Write the following arithmetic assignment statements in Mathematica and
assign values to the variables involved and evaluate the formula

f = - pi/2 log |x| + a/x -a^3/(9x^3)

b = (e^(x/Sqrt(2) cos(Sqrt(x/2) + pi/8)/Sqrt(2pix)