1.1.1 Use scipy.integrate.romberg to evaluate the triple integral
dz dy dx
1 + x
2 + y
2 + z
Try to obtain results for a range of precision eg. tol=1e-3, 1e-4, ... See how small you can make
the tolerance and still obtain a result in under a minute or so. (It may be helpful to adjust divmax.)
Determine the number of calls N to the integrand
1 + x
2 + y
2 + z
required for each value of tol. Plot the graph of N versus tol and discuss the result.
1.1.2 A transformation from Cartesian to spherical coordinates changes the integral into the
sin ϕ dρ dϕ dθ
1 + ρ
Apply the same methods as in the previous section to evaluate the triple integral in spherical
coordinates. Compare and discuss your results.
Use a Jupyter notebook with an .ipynb extension to write up this assignment and submit it
The name and UCID of each co-author must be included near the beginning.
Each notebook should have an introduction and conclusion/summary/discussion section.
Each graph must have a title, axis labels, and any other features required to make it easier to
understand eg. a legend.
Use graphs or tables instead of printing large blocks (ie. pages) of numbers.
Each non-trivial function should have a docstring.
Avoid duplication of code. Use functions and loops instead of cutting and pasting the same
lines in multiple places.
Describe what you did and explain why you did it. When you are writing your report, think
back to what you wish you had known when you started.
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.
# Import python science module
# Import integrate functions from python science module
from scipy import integrate
# Import python numerical module
import numpy as np
# Import python plotting module
import matplotlib.pyplot as plt
# Suppress warnings
global_tol = 1e-4
global_n = 0
# Method to represent integrand function: f(x,y,z)
# This is the innermost function which will be integrated.
def integrand(z, y, x):
global_n += 1
# Method to represent integral function with respect to z.
# This is the innermost integral function.
def integraldz(y, x):