to read my Mathematica Lab!

Mathematica Lab #12
Problem 1
Compute the product of the consecutive integers 4 through 9 two seperate ways.
1. Using a For Statement
ClearAll;
product=1;
For[i=4,i≤9,i++,product=product*i];
product
60 480
2. Using the Product Command
Product[i,{i,4,9}]
60 480
Problem 2
Compute the sum of the first 25 prime numbers.
Sum[Prime[i], {i,1,25}]
1060
Problem 3
Compute the square root of the sum of the squares of the integers 15 through 30, inclusive.
Sqrt[Sum[i^2, {i,15,30}]]
2
2110
Problem 4
Compute the infinite sum 1 +
1
2
+
1
4
1
+ 8+
1
...
16
Sum[1/(2^x),{x,0,∞}]
2
Printed by Wolfram Mathematica Student Edition
2
a_lab12_2015.2016_bhamilton.nb
Problem 5
Sketch the graphs of y=sin[x], y=2sin[x], y=3sin[x] for -π ≤ x ≤ π, on one set of axes.
plotone=Plot[Sin[x], {x,-Pi,Pi}, Ticks→{{-Pi,-3/4Pi,-1/2Pi,-1/4Pi,0,1/4Pi,1/2Pi,3/4Pi,Pi}
AxesLabel→{x,y},PlotLegends→{"y=sin[x]"},PlotStyle→{ColorData["Crayola"]["Fern"]},PlotRange
plottwo=Plot[2Sin[x], {x,-Pi,Pi}, Ticks→{{-Pi,-3/4Pi,-1/2Pi,-1/4Pi,0,1/4Pi,1/2Pi,3/4Pi,Pi
AxesLabel→{x,y},PlotLegends→{"y=2sin[x]"},PlotStyle→{ColorData["Crayola"]["BlueGray"]},PlotRange
plotthree=Plot[3Sin[x], {x,-Pi,Pi}, Ticks→{{-Pi,-3/4Pi,-1/2Pi,-1/4Pi,0,1/4Pi,1/2Pi,3/4Pi,
AxesLabel→{x,y},PlotLegends→{"y=3sin[x]"},PlotStyle→{ColorData["Crayola"]["OuterSpace"]},
Show[plotone,plottwo,plotthree]
y
3
2
y=sin[x]
1
-π
-
3π
4
-
π
2
-
π
π
π
3π
4
4
2
4
x
π
-1
y=2sin[x]
y=3sin[x]
-2
-3
Problem 6
How many zeros does the function f(x)=x2 -ⅇ0.1 x have? Provide a good graphical representation of this
problem.
Printed by Wolfram Mathematica Student Edition
a_lab12_2015.2016_bhamilton.nb
3
ClearAll;
Plot[x^2-E^(0.1x), {x,-400,400},AxesLabel→{x,y},PlotStyle→{ColorData["Atoms"]["Li"]},PlotLabel
Plot[x^2-E^(0.1x), {x,-100,100},AxesLabel→{x,y},PlotStyle→{ColorData["Atoms"]["Li"]},PlotLabel
Plot[x^2-E^(0.1x), {x,-5,5},AxesLabel→{x,y},PlotStyle→{ColorData["Atoms"]["Li"]},PlotLabel
-400<x<400
y
-400
-200
200
400
50
100
x
-1 × 1011
-2 × 1011
-3 × 1011
-4 × 1011
-5 × 1011
-100<x<100
y
10 000
5000
-100
-50
x
-5000
-5,x,5
y
25
20
15
10
5
-4
-2
2
4
x
As seen by the two above graphs, there are three zeros.
Printed by Wolfram Mathematica Student Edition
4
a_lab12_2015.2016_bhamilton.nb
Problem 7
Compute the product of the first twenty Fibonacci numbers two different ways.
1. Using the Product Command
Product[Fibonacci[i],{i,1,20}]
9 692 987 370 815 489 224 102 512 784 450 560 000
2. Using the For Statement
product=1;
For[i=1,i≤20,i++,product=Fibonacci[i]*product];
product
9 692 987 370 815 489 224 102 512 784 450 560 000
Problem 8
If 35 x+1 = 11 then x ≈ ?
NSolve[5x+1==Log[3,11], x]
{{x → 0.236532}}
Problem 9
Compute the sum
1
2
+
2
3
+
3
4
+
4
5
+ ... +
99
.
100
Sum[x/(x+1),{x,1,99}]
264 414 864 639 329 557 497 913 717 698 145 082 779 489
2 788 815 009 188 499 086 581 352 357 412 492 142 272
Problem 10
1
Compute the sum 1 + 1 + 2  + 1 +
1
2
1
+ 3  + ... + 1 +
1
2
+
1
3
+ ... +
1. The Summation within the Summation
Sum[Sum[1/x,{x,1,y}],{y,1,20}]
41 054 655
739 024
2. Using a For Statement and a Summation
Printed by Wolfram Mathematica Student Edition
1

20
at least two ways.
a_lab12_2015.2016_bhamilton.nb
tot=0;
For[i=1,i≤20,i++,tot=tot+Sum[1/x,{x,1,i}]];
tot
41 054 655
739 024
Printed by Wolfram Mathematica Student Edition
5