Exercise 1h) - Testing the solve function 1p Write two tests where you test that both...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Exercise 1h) - Testing the solve function 1p Write two tests where you test that both the time array and the solution to the ODE is correct test_solve_time: Should make sure that: • The first time point is zero. The last time point is T. • The difference between the second and first time point is dt. test_solve_solution: Should make sure that the relative error of the difference between the exact and computed is within 1%. • Both tests should be parametrized using pytest.mark.parametrize with respect to a, up, T and dt and test at least three different inputs. Hint - Comparing with the exact solution The exact solution of the exponential decay ODE is given by u(t)= use Hint - Computing the relative error If you have the compute solution y and the exact solution y_exact then you can compute the relative error as import numpy as np relative_error = np. linalg.norm(y- y_exact) /np.linalg.nor Exercise 1h) - Testing the solve function 1p Write two tests where you test that both the time array and the solution to the ODE is correct test_solve_time: Should make sure that: • The first time point is zero. The last time point is T. • The difference between the second and first time point is dt. test_solve_solution: Should make sure that the relative error of the difference between the exact and computed is within 1%. • Both tests should be parametrized using pytest.mark.parametrize with respect to a, up, T and dt and test at least three different inputs. Hint - Comparing with the exact solution The exact solution of the exponential decay ODE is given by u(t)= use Hint - Computing the relative error If you have the compute solution y and the exact solution y_exact then you can compute the relative error as import numpy as np relative_error = np. linalg.norm(y- y_exact) /np.linalg.nor
Expert Answer:
Answer rating: 100% (QA)
The exercise is about creating tests to verify the correctness of a solution to an ordinary differential equation ODE obtained through a solve functio... View the full answer
Related Book For
Auditing Cases An Interactive Learning Approach
ISBN: 9780134421827
7th Edition
Authors: Mark S Beasley, Frank A. Buckless, Steven M. Glover, Douglas F Prawitt
Posted Date:
Students also viewed these programming questions
-
What role does civic engagement and participatory democracy play in fostering social cohesion and collective action, and how do theories of deliberative democracy and participatory governance provide...
-
What is negative gearing? Discuss the risks of this approach for: (a) Investors with young families (b) Retirees.
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Solve the equation symbolically. Then solve the related inequality. 1 - X
-
Unpolarized light in vacuum is incident onto a sheet of glass with index of refraction n. The reflected and refracted rays are perpendicular to each other. Find the angle of incidence. This angle is...
-
Grant Foundry Inc. manufactures custom metal products that require casting, such as engine blocks, pistons, and engine housings. During the current period an order for 5,000 custom housings was begun...
-
The data set lists the out-of-pocket prescription medicine expenses (in dollars) for 30 U.S. adults in a recent year. Construct a frequency distribution that has seven classes. 200 239 155 252 384...
-
LaToya Company produces door pulls, which are inspected at the end of production. Spoilage may occur because the door pull is improperly stamped or molded. Any spoilage in excess of 3 percent of the...
-
The amount of time it takes for a taxpayer to receive his / her tax refund from the IRS after filing is normally distributed. For the 2 0 2 4 tax season, the agency said 1 0 % of taxpayers will...
-
Pool Corporation, Inc., sells swimming pool supplies and equipment. It is a publicly traded corporation that trades on the NASDAQ exchange. The majority of Pools customers are small, family-owned...
-
Describe how the optimal allocation of consumption over time is determined in this version of the DD model. For simplicity, you can assume no discounting (p = 1 in DD's notation). A good starting...
-
5:10 PM Sun Nov 5 Question 17 of 22 1 4 7 +/- Tap here or pull up for additional resources When copper is heated with an excess of sulfur, copper (1) sulfide is formed. In a given experiment, 0.0970...
-
Merck & Company: Evaluating a Drug Licensing Opportunity Rich Kender, Vice President of Financial Evaluation & Analysis at Merck, was working with his team to decide whether his company should...
-
Express the equilibrium constant for the following reaction. 2 C4H10(9)+13 O2(g) = 8 CO2(g) + 10 HO(l) K= [CO,18 13 [0] 3 K= K=- [CO,][H,O]10 [CH 101002113 K= [CH 10 13 [CO] [CO]8 [CH1013 4 [CH013...
-
What are the evolutionary mechanisms underlying the origin of novel adaptations, phenotypic innovations, and evolutionary novelties, including gene duplication, gene recruitment, co-option, and...
-
Module Six Assignment For each scenario listed below, identify the steps the consumer should take in order to get a refund or replacement based on consumer protection laws. Explain what might happen...
-
What men need to know in order to understand gender inequality in the workplace and the family
-
Compare and contrast debt financing and equity financing as ways of starting a new business. Does one have an overall advantage over the other? What situation is more favorable to the use of debt...
-
Tina is an audit manager with a national public accounting firm and one of her clients is Simply Steam, Co. Simply Steam provides industrial and domestic carpet steam-cleaning services. This is the...
-
Ted is an audit manager with a national public accounting firm and one of his clients is Easy Clean, Co. Easy Clean provides industrial and domestic carpet steam-cleaning services. This is the first...
-
Town and Country Hardware (T&CH) is a closely owned business founded six years ago by Caleb and Jasmine Wright. T&CH has retail hardware stores located at three lake communities along the Virginia...
-
a. In Experiment 4A, set the sample frequency to 50 msec and measure the phase margin. b. Compare this with the phase margin with a 1-msec sample time (same as Question 1c). (DATA FROM QUETION 1C) c....
-
a. Using the DSA in Experiment 4A to generate open-loop Bode plots, what is the phase margin when the sample time is set to its default (0.00025 sec)? b. Repeat with a sample time of 0.0005 sec. c....
-
Using Experiment 3A, follow the zone-based tuning procedure of Section 3.5 using a square wave command with the following criteria: For KP, allow no overshoot. For KI, allow about 10% overshoot. a....
Study smarter with the SolutionInn App