• Home
  • Textbooks
  • Computer science with Mathematica: theory and practice for science, mathematics, and engineering
  • Mathematica's Programming Language

Computer science with Mathematica: theory and practice for science, mathematics, and engineering

Roman Maeder

Chapter 2

Mathematica's Programming Language - all with Video Answers

Educators


Chapter Questions

03:10

Problem 1

1. Go through the examples given in Sections 2.1-2.3, and determine the internal forms of the expressions that occur in these examples. Mathematica can help you; see Section 2.4.3.
2. What is the internal form of these expressions before evaluation?
a. $f @\{a, b, c\}$
b. $f /@\{a, b, c\}$
c. $f @@\{a, b, c\}$

Carole Wastog
Carole Wastog
Numerade Educator
03:36

Problem 2

Investigate this expression:
$$
f^{\prime}[x+1] / 5 \text { ! }
$$
1. Write the expression in internal form, without using any operators.
2. Denote the building blocks of the expression, that is, head and elements. Continue in this way with any parts that are still composite. Give the type of atomic parts.
3. To what does this expression evaluate?

Charles Carter
Charles Carter
Numerade Educator
05:34

Problem 3

Give the result of evaluating the following expressions. If there are any nested functions, also give the most important intermediate steps. Assume that each example is evaluated in a fresh Mathematica session. Consecutive expressions in one example are evaluated one after another in the same session.
1. $\operatorname{Sum}[z \wedge i / i !,\{i, 0,4\}]$
2. $\operatorname{Sum}[\operatorname{Product}[(x-i) \wedge j,\{i, 0,2\}],\{j, 2\}]$
3. Expand[ Product $[x-i,\{i,-2,2\}]]$
4. $\{1,2,3\} \wedge 2+1$
5.$\begin{aligned} & a=5 ; b:=6 ; \\ & c=a ; d=b ; \\ & e:=a ; f:=b ; \\ & a=7 ; b:=8 ; \\ & \{a, b, c, d, e, f\}\end{aligned}$

Willis James
Willis James
Numerade Educator
12:50

Problem 4

For positive reals $a$ and $g$, the two sequences $a_i$ and $b_i$, with
$$
\begin{aligned}
a_0 & =a \\
g_0 & =g \\
a_{i+1} & =\frac{a_i+g_i}{2} \\
g_{i+1} & =\sqrt{a_i g_i}
\end{aligned}
$$
converge to a common limit. Observe that $a_{i+1}$ is the arithmetic mean of $a_i$ and $g_i$, and that $g_{i+1}$ is the geometric mean.
1. Compute the common limit numerically for a few values of $a$ and $g$ with a simple While loop.
2. Define a function AGM $[a, g]$ that computes this limit.

M Z
M Z
Numerade Educator