Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / MENG 21200 -  Principles of Engineering Analysis II                                      Problem Set 7   Problem 1 - Methods to solve sets of linear equations Solve the following system of equations using the indicated methods:   ?1 + 2?2 + 3?3 − 5?4 = −44 2?1 + 5?2 + 4?3 − ?4 = 8 ?1 − ?2 + 10?3 + 2?4 = 44 3?1 − 2?2 + 5?3 − 3?4 = −16   The python library function np

MENG 21200 -  Principles of Engineering Analysis II                                      Problem Set 7   Problem 1 - Methods to solve sets of linear equations Solve the following system of equations using the indicated methods:   ?1 + 2?2 + 3?3 − 5?4 = −44 2?1 + 5?2 + 4?3 − ?4 = 8 ?1 − ?2 + 10?3 + 2?4 = 44 3?1 − 2?2 + 5?3 − 3?4 = −16   The python library function np

Math

MENG 21200 -  Principles of Engineering Analysis II                                     

Problem Set 7  

Problem 1 - Methods to solve sets of linear equations

Solve the following system of equations using the indicated methods:

 

?1 + 2?2 + 3?3 − 5?4 = −44

2?1 + 5?2 + 4?3 − ?4 = 8

?1 − ?2 + 10?3 + 2?4 = 44

3?1 − 2?2 + 5?3 − 3?4 = −16

 

  1. The python library function np.linalg.solve.
  2. The Gauss-Seidel method without relaxation.  Plot  versus iteration number.
  3. The Gauss-Seidel method with relaxation (? = 0.95).  Plot  versus iteration number.

 

 

Problem 2 – Comparing numerical methods to solve sets of nonlinear equations 

Solve this system of equations in Jupyter Notebook by implementing the following methods from scratch. 

3?1?2 + ?2 − ?3 = 12

?1 − ?21?2 + ?3 = 12 ?1 − ?2 − ?3 = −2

 

  1. Multi-equation Newton-Raphson method (see Sections 6.6 and 9.6 of C&C).
  2. The successive substitution method (see Section 6.1 of C&C).

Problem 3 –  Ignoring safety considerations…

Adapted from Chapra and Canale, Problem 13.22.

Use the golden-section search method to determine the length of the shortest ladder that reaches from the ground over the fence to touch the building’s wall (see figure at right).  

  1. Write your own code for the golden-section search method.  Demonstrate your code to determine the shortest ladder possible for the case where ? = ? = 6 ?.
  2. Demonstrate the application of the scipy.optimize.golden function in python to find the minimum.
  3. Note that the golden function is a ‘legacy’ function still available in Python, but is no longer recommended for use.  Instead, please demonstrate the application of the scipy.optimize.minimize_scalar function.
  4. Prepare a plot of the length of the shortest ladder versus  for the case where ? = 6 ?.  Consider distances between the fence and wall up to 20 ? (i.e., 0 ≤ ? ≤ 20 ?).   

 

 

Problem 4 – Multivariate linear regression - A hint of the power of machine learning

In this problem we will do some basic machine learning on the sklearn.datasets.load_boston dataset which is provided within the scikit learn

(sklearn) library.

 

  1. Read the documentation on the sklearn website and identify what information is stored in the variables RM, LSTAT, and MEDV of the Boston dataset. 
  2. Determine from the documentation how to load the RM, LSTAT, and MEDV data into a pandas dataframe.  Remove the last row of the dataset and save it into a separate dataframe for testing your model against later.  
  3. Plot the scatter matrix of the data using pd.plotting.scatter_matrix.
  4. Write a function to calculate the univariate linear fit between RM and MEDV, as well as between LSTAT and MEDV.  Plot the fit lines against the scattered data.  Calculate the R2 and RMSE of each fit.  Which is a better measure of goodness of fit in your opinion for each regression?  Use these fits to calculate the ‘predicted’ MEDV for the test data point that you reserved in part (b).  Which regression does a better job of predicting the true value of MEDV for the test data point?
  5. Now write your own function that performs a multivariate linear regression and use it to calculate the fit on variables RM and LSTAT versus the variable MEDV.  Plot the fit plane against the scattered data in a 3D plot.  Again calculate the R2 and RMSE, and state which is a better measure of goodness of fit. 
  6. Apply your multivariate fit to predict the MEDV of the test data point.  How well does the multivariate fit predict the actual value as compared to the linear fits calculated in part (d)?

 

 

Problem 5 – Solving the time-dependent Heat Equation with finite difference methods

Imagine an insulated iron rod that only exchanges heat with its surroundings at each end.  Consider the length of the rod to be 1 m for simplicity.  One end of the rod is fixed at room temperature (300 K), and the other end of the rod is immersed in hot oil (500 K) and immediately equilibrates at that temperature.  You may want to check out some online resources for getting some intuition on this physics if you have not encountered transport phenomena before:  here is a 3blue1brown video, and some notes from Paul’s Math Notes.

 

 

The heat equation describes the process of heat diffusion, i.e., how the spatial distribution of temperature in a material changes as a function of time.  The temperature distribution ?(??, ?) is a scalar field on  ?? = (?, ?,?) coordinates and changes with time .  The heat equation for a homogeneous material is

 

where ?, ?, and ?0 are the heat capacity, mass density, and thermal conductivity of the rod material, respectively.  In the absence of a heat source , the equation in one-dimension simplifies to

 

 

where  is a constant dependent on the aforementioned material properties.  

In order to model the temperature distribution within the rod using numerical methods, we will discretize the rod into even-length segments and compute the temperature at the nodes to satisfy the boundary value problem.  Let  be number of nodes, and ? − 1 be the number of segments rod. 

 

  1. Assuming that the rod is made of iron, look up the value and units of  for iron online.  Is the differential equation that defines the system dimensionally consistent (i.e., are the units the same on both sides of the equation)?
  2. What is the initial temperature distribution within the rod (i.e., ?  
  3. What are the boundary value conditions? 
  4. Start with ? = 6 (labeled 0 to 5). Denote the temperatures at each node as ??(?).

Write expressions for  for the internal nodes 1 to 4 using the first-centered difference.  Write similar expressions using the first-forward difference for node 0 at the end of the rod in the air (? = 0), and the first-backward difference for node 5 at the end of the rod in the hot oil (? = 1 ?).  Write your solution as a matrix  such that 

 

 

  1. Define a function in a Jupyter Notebook that generates  for an arbitrary .  Verify that it works by generating the discrete datapoints of a known function ? = sin 2?? and compare ? ⋅ ??? to the analytical second-order derivative in a plot.  Demonstrate your function works for a ? > 40.
  2. Using this Laplacian operator that you have defined, we can compute the right-hand side for any temperature profile at any point in time. Here we will handle the evolution in time by integrating using a forward-Euler method (note that in practice, the Crank-Nicolson algorithm is more common).  Please look at Chapter 30 in C&C for how this is done (Section 30.2 on explicit methods and equations 30.2-30.5) and write your own function for solving the heat equation.  You can fill in the framework we provided or write your own integrator.
  3. Solve the system with ? = 41 nodes and a time step of ?? = 1.0 ?.  Integrate up to 3 hours.  Present your result as an overlay of plots of the temperature profile T versus x for every 20 min.
  4. According to the definitions in C&C, what is the value of  for the time step we used? Show on a plot what happens if you choose a time step that is too large.  What is the max time step we can use without causing an instability in the solution? 
  5. The steady-state condition is reached when ??/?? = 0. What is the steady-state solution to the heat equation?  Solve using either your own shooting method code or scipy.integrate.solve_bvp.
  6. Does the system reach steady-state in 5 hrs?  Plot the temperature at ? = 0.5 ? versus time.  Indicate the steady-state value with a horizontal line, and calculate the percentage of difference from the steady state at ? = 5 ???.
  7. The function from part (e) can be easily modified to incorporate external heat sources. Make the modification and solve again for the first 60 min of heating with

 

which is the model for heating a metal rod with a torch at its mid-point, e.g., if we wanted to bend it.  Assume that the two ends of the rods are fixed at 300 K.

  1. You want to bend the bar when it reaches a temperature of 600 K at the center.  How long does it take to reach this condition? 

 

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE