Answered step by step
Verified Expert Solution
Question
1 Approved Answer
*** PLEASE EXPLAIN ALL LINES OF CODE USING THE # OPTION IN YOUR CODE. MAKE SURE TO DEFINE A MAIN() FUNCTION BELOW. I AM USING
*** PLEASE EXPLAIN ALL LINES OF CODE USING THE "#" OPTION IN YOUR CODE. MAKE SURE TO DEFINE A MAIN() FUNCTION BELOW. I AM USING SPYDER.***
You will write three Python files named hwwapy,hwwbpp, and hwwc.py. Those programs will fulfill all of the requirements given in parts a,b, and c below. You will place those four python files into a single compressed file named firstname_lastname_hw2.zip. You will upload the .zip file to the Homework 2 dropbox. You will test your functions and using the particular numerical values and function calls given. When we grade your assignment, we will run your program with those given numerical values, looking for correct answers. For now, you may not use any of the powerful functions available in python modules, with two exceptions: you may import functions from the math module and the copy module. You must include reasonable comments in your code. See your MAE 3013 textbook or online materials for a reminder of: The Secant Method for finding the solution (root or zero) or a nonlinear equation The Simpson's 1/3 rule for numerical integration The Gauss-Jacobi and Gauss-Seidel methods for solving a set of linear equations a) Write a function defined as: def Simpson(func, a, b, npoints = 30): Purpose: use Simpson's 1/3 rule to estimate the integral of func(x), between the limits of a and b. func: the function we want to integrate a and b: the lower and upper limits of integration npoints: The number of integration points used in the range a to b (inclusive). Npoints must be an ODD number. If npoints is not ODD, then add 1 to make it odd! return value: the estimate of the integral Write and call a main() function that uses your Simpson function to estimate the value of the integral. The main function will print the value of integral. Use the following 3 test cases: 2x3sin(x)cos(2x)x3cos(2x)x3witha=2,b=3andnpoints=9witha=3,b=4andnpoints=27witha=2,b=3withnpointsunspecified
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started