Lab3_final
pdf
keyboard_arrow_up
School
Texas A&M University *
*We aren’t endorsed by this school
Course
152
Subject
Mathematics
Date
Feb 20, 2024
Type
Pages
5
Uploaded by MasterFireHeron35
MATH 152 Lab 3
Samuel Molero, Angus Ladd, Arlin Birkby, Karthik Nuti
Instructions: Complete the lab assignment in your assigned groups. Unless stated otherwise,
your answers should be obtained using Python code.
Do not modify the cell above, as it contains all the packages you will need. It is highly
recommended to not use any additional packages.
NOTE: If you took MATH 151 last semester, notice that the import statement for SymPy is
di
ff
erent- for each SymPy command you use, you have to preface it with "sp." For example,
"symbols('x')" becomes "sp.symbols('x')". Except for plot and plot_parametric
- you don't
need to type "sp." for those.
ANOTHER NOTE: Approximate answers are acceptable for all non-plotting parts of this
week's lab.
Question 1
1a
In
[3]:
import
sympy
as
sp
from
sympy.plotting
import
(
plot
,
plot_parametric
)
In
[5]:
x
=
sp
.
symbols
(
'x'
,
real
=
True
)
f_x
=
sp
.
sqrt
(
x
)
g_x
=
(
x
-
3
)
**
2
p1
=
plot
(
f_x
,(
x
,
0
,
5
),
show
=
False
)
p2
=
plot
(
g_x
,(
x
,
0
,
5
),
show
=
False
)
p1
.
extend
(
p2
)
p1
.
show
()
Lab3temp_152_23C
http://localhost:8888/nbconvert/html/Desktop/152/Lab...
1 of 5
9/27/23, 11:33 PM
1b
The Volume of the solid rotating at about x = 1 is: 1c
In
[6]:
#rotating abou the line x = 1
formula
=
(
2
*
sp
.
pi
)
*
(
g_x
-
f_x
)
*
(
x
-
1
)
intervals
=
sp
.
solve
(
f_x
-
g_x
,
x
)
new_intervals
=
[]
for
i
in
intervals
:
new_intervals
.
append
(
i
.
evalf
())
volume
=
sp
.
integrate
(
formula
,(
x
,
new_intervals
[
0
],
new_intervals
[
1
]))
print
(
"The Volume of the solid rotating at about x = 1 is: "
)
display
(
volume
.
evalf
())
41.1718167309256
Lab3temp_152_23C
http://localhost:8888/nbconvert/html/Desktop/152/Lab...
2 of 5
9/27/23, 11:33 PM
Volume of the solid rotating at about y = 4
Question 2
2a
In
[22]:
# Enter your Python code here
# Enter your Python code here
y
=
sp
.
symbols
(
'y'
,
real
=
True
)
f_y
=
sp
.
solve
(
f_x
-
y
,
x
)[
0
]
g_y
=
sp
.
solve
(
g_x
-
y
,
x
)[
0
]
intervals
=
sp
.
solve
(
f_y
-
g_y
,
y
)
new_y
=
[]
for
i
in
intervals
:
new_y
.
append
(
i
.
evalf
())
formula
=
2
*
sp
.
pi
*
(
f_y
-
g_y
)
*
(
y
-
4
)
volume
=
sp
.
integrate
(
formula
,(
y
,
0
,
new_y
[
0
]))
print
(
"Volume of the solid rotating at about y = 4"
)
display
(
volume
.
evalf
())
48.2575581197776
In
[23]:
# Enter your Python code here
f_x
=
2
*
sp
.
E
**
(
x
**
2
)
g_x
=
3
*
x
+
2
# display(f_x,g_x)
p1
=
plot
(
f_x
,(
x
,
0
,
1
),
show
=
False
)
p2
=
plot
(
g_x
,(
x
,
0
,
1
),
show
=
False
)
p1
.
extend
(
p2
)
p1
.
show
()
Lab3temp_152_23C
http://localhost:8888/nbconvert/html/Desktop/152/Lab...
3 of 5
9/27/23, 11:33 PM
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
2b
The volume of the solid is: Question 3
3a
In
[14]:
# Enter your Python code here
interval_1
=
sp
.
nsolve
(
f_x
-
g_x
,(
0
))
interval_2
=
sp
.
nsolve
(
f_x
-
g_x
,(
0.9
))
formula
=
(
sp
.
sqrt
(
3
)
/
4
)
*
(
g_x
-
f_x
)
**
2
volume
=
sp
.
integrate
(
formula
,(
x
,
interval_1
,
interval_2
))
print
(
"The volume of the solid is: "
)
display
(
volume
.
evalf
())
0.191894750193957
Lab3temp_152_23C
http://localhost:8888/nbconvert/html/Desktop/152/Lab...
4 of 5
9/27/23, 11:33 PM
3b
3c
In
[12]:
p
=
900
g
=
9.8
y
=
sp
.
symbols
(
'y'
,
real
=
True
,
positive
=
True
)
#intervals 0 - 20
# r^2 + y^2 = 20^2
formula
=
(
sp
.
pi
*
(
p
*
g
))
*
(
400
-
y
**
2
)
*
(
22
-
y
)
#display(formula)
work
=
sp
.
integrate
(
formula
,(
y
,
-
20
,
20
))
display
(
work
)
2069760000.0
π
In
[13]:
h
=
sp
.
symbols
(
'h'
,
real
=
True
,
positive
=
True
)
formula
=
((
400
-
(
20
-
y
)
**
2
)
*
(
42
-
y
))
a
=
sp
.
integrate
(
formula
,(
y
,
0
,
40
-
h
))
display
(
a
*
(
900
*
9.8
*
sp
.
pi
))
8820.0
π
(
−
+ 840(40
−
h
)
2
)
(40
−
h
)
4
4
82(40
−
h
)
3
3
Lab3temp_152_23C
http://localhost:8888/nbconvert/html/Desktop/152/Lab...
5 of 5
9/27/23, 11:33 PM