Question: Please do problems 1 and 2 using Python. For parts that require written explanation, use the print() function to print your answers to the screen

Please do problems 1 and 2 using Python.

Please do problems 1 and 2 using Python. For parts that requirewritten explanation, use the print() function to print your answers to the

For parts that require written explanation, use the print() function to print your answers to the screen when the script is run. Remember that unlike with using the python interpreter (e.g. Python in "live" mode by running Python in the shell prompt window), commands will not print out to the screen automatically when run through a scripting file. Make sure that your scripts run without error in order to get credit. Do not hesitate to ask for help if needed! Problem 1 Python functions to create a data file (7 pts) (a) Define 2 Python functions that return respectively f(x) = sin(x+2) and g(x) 10-23 10+223 (b) Define a Python function of 3 variables h(x, y, z) = cos(x + y2); We will then want to generate data using these functions and write it to a file. More specif- ically, we want to calculate r, y = f(x), z = g(x), h(x, y, z) for 1001 values of x uniformly spaced between 0 and 27 inclusive (i.e., including 0 and 27 among the 1001 points). Call the data file data.dat (we'll usually use .dat extensions for data files). It should contain 4 columns, and you'll want to make sure that the numbers are aligned in nice columns (Hint: use format). Problem 2 Taylor (Maclaurin) series functions (8 pts) We want to write a Python script that can compute the sum of the Maclaurin series for sin(x), cos(x) and exp(x) for a given value of x and a given value of terms that need to be added. You will do this by writing 3 functions: sine_series, cosine_series and exp_series, respectively. However, you are not allowed to use the math.factorial command nor the sum command, so you will need to write two separate functions for these that you can call inside your 3 functions. Once you have written these 3 functions, you can write 3 much shorter and simpler func- tions, sine_series_simple, cosine_series_simple and exp_series_simple that do the same but can make use of the math.factorial and sum commands, and make use of list comprehension to calculate things very simply

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!