a. Execute this example of a function definition: def h(x): return sum ([sin (n*x)/n for n in srange (1, 20.0)]) b. Evaluate h(x), a

a. Execute this example of a function definition def h(x): return sum (tsin(nx)/n for n in srange (1,20.0)1 b. Evaluate h(x), and plot h(x) for x between 0 and 4 pi. c. Define a function that is equal to 2*x for x>O,and equal to-3*x for x <O. Plot the function to verify it behaves correcetly. Hint you will need to use an if statement.) . a Make a modified version of the function below -rename it to Simp int, change the documentation (docstring) accordingly, and have it compute a numerical integral using Simpsons rule instead of the trapezoid rule. Simpsons rule is b. Show the output of the original function, your function, and the command integnate for(e)rom a 0 t 1, with 10 ubdivisions of the integration interval. def trap int (f, a,b,n) : - #7hetriple quotes indicate a multiline comment, or ,docstring. Trapezoid rule numerical integrater. Inputs: f: a function of one variable, x a: the lower endpoint of integration b: the upper endpoint of integration n: the number of subdivisions forces floating-point computation # the size of the x-axis increment nn float (n) delx = (b-a) /nn answer. delx*(f(x-a1+f(x-b))/2.0 # endpoints of sum ore weighted differently for i in range (1,n) thia loops over the interior of the su answer delxf(xa delx) return float (answer) 6. Use the plot slope_field command to sketch the logistic vector field corresponding to the ODE y-4*y - y), for t in (05) and y in (-1,2) 7. When your lab is complete, change the name (by clicking on it) of the lab to: Labl-Yourl astName-YourFirst Name. a- sqrt(3) print(nla, digits -100)) 1.7320508075688772935274463415058723669428052538103806280558069794519330 16908800037081146186757248576 )槨 Please code in sage or python

a. Execute this example of a function definition: def h(x): return sum ([sin (n*x)/n for n in srange (1, 20.0)]) b. Evaluate h(x), and plot h(x) for x between 0 and 4*pi. c. Define a function that is equal to 2* x for x > 0, and equal to -3*x for x

Expert Answer

 

from math import sin, pi
import matplotlib.pyplot as plt

def h(x):
return sum([sin(n*x)/n for n in srange(1, 20.0)])

def frange(start, stop, step):
res = []
x = start
while x < stop:
res.append(x)
x += step
return res

x = srange(0, 4*pi)
y = [h(i) for i in x]
plt.plot(x, y)

def myfunc(x):
if x > 0:
return 2*x
else:
return -3*x

x = frange(-3, 3, 0.1)
y = [myfunc(i) for i in x]
plt.plot(x, y)

# code link: https://paste.ee/p/cy6ay (please add your statement for importing srange or use my frange method)

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?