Python Lab Tutorials: Lab 2
- Consider the relationship
Using Sympy, find and . Evaluate , , and at . Then, using Matplotlib, plot the relationships , , and for the domain by first finding the y-values using a “for
” loop and a list. Label your plot and plot legend appropriately. - Consider the sequence whose terms are . Use Sympy to evaluate the sum of the first twenty terms. Then, evaluate the infinite sum:
Use Matplotlib to plot the first ten terms of the ordered pairs . Label the plot appropriately. - Consider the matrix
Use Matplotlib and Sympy to plot the relationship between the determinant of and for . Label the plot appropriately. From the plot, can you identify the values of for which the determinant is equal to zero? - The function where is in radian can be represented as the infinite series:
Let i+1 be the number of terms used to approximate the function . Using Numpy, create a function in Python whose inputs are and and whose output is the approximation:
Show using numerical examples that your function gives proper approximations by comparing its output with the built-in function in Numpy.
Extra Practice Problems
- The function where is in radian can be represented as the infinite series:
Let i+1 be the number of terms used to approximate the function . Using Numpy, create a function in Python whose inputs are and and whose output is the approximation:
Show using numerical examples that your function gives proper approximations by comparing its output with the built-in function in Numpy. - The discharge velocity through an orifice at the bottom of a water tank open to the atmosphere is given by the relationship:
where is the height of the water left in the tank. If is the “effective” area of the orifice and is the cross sectional area of the tank, then the following differential equation describes the rate of change of the height of the water left in the tank
Assuming that at the height of the water in the tank is given by , use the Sympy’sdsolve
function to solve the above differential equation using Python to find the height as a function of , , , , and . Then, use the “Solve” function to show that the time to empty the tank (i.e., the time at which ) is given by the expression: - In Sympy or Numpy, write two functions in Python whose arguments are a matrix and a vector. The first function should output the matrix after replacing the last row with the given vector. The second function should output the matrix after replacing the last column with the given vector.