You will create an executable Python program for each task and you can finally collect them in a .py file and add. Additionally present a printout exhibiting the outcomes of Workouts 1, 2 and Three.
Task 1 The weierstrass.py weierstrass.py incorporates a operate w wanted for this task, so obtain it and place it in the identical folder because the file you are about to submit. Right here you must program (Python):
1. Plot the operate w on the interval [-2, 2]. Strive totally different values for num in np.linspace for how advantageous division of the x-axis in np.linspace you want to point out sufficient particulars.
Then create a operate referred to as wderivert (x, h) that makes use of a technique that calculates the by-product in each of the factors you outlined in 1. for a given h = zero.001.
Three. Plot the by-product. What can you say in regards to the operate w based mostly on what you see.
four. Strive totally different values of num underneath 30 to seek out your favourite graph of the by-product of w and go away this worth as the ultimate worth for the division of the x-axis for all of the plots.
Task 2
On this train we will use numerical integration on the operate
We will use Simpson’s rule, which approximates the operate as a collection of quadratic capabilities that undergo the endpoints and midpoints of the subintervals. The determine exhibits Simpson’s rule for the operate just like ours on the interval [2, 8].
You can learn extra about Simpson’s rule (Simpson’s rule in English) ) her. The Norwegian Wikipedia article additionally has some tips about how the strategy can be applied, and can be learn right here. her. (Lenker til eit ekstern område.) Word the distinction between dividing into n subintervals (plus their midpoint) and dividing into 2n subintervals (the place a number of the divisions are the midpoints). The latter is the strategy we wish.
1- Divide the interval [2, 8] into 2 equal sub-intervals and use Simpsons rule to calculate the integral.
2- Repeat step 1, however use 5, 10, and 100 subintervals. What occurs to the worth of the integral? Can you guess what the true integral is? Primarily based on the picture above, what’s the minimal variety of sub-intervals you anticipate to supply a good method? Three- Use Simpson’s rule on
on the similar interval. What do you discover when you attempt totally different variety of sub-intervals? Can Simpson’s method take odd quantity intervals? Can you clarify this?
Task Three
Write a Python operate (not a script) that calculates the realm of a circle sector. The operate ought to take a radius, referred to as r, and an angle given in radians, referred to as theta (theta is the Greek letter that can be written ?) as arguments, and begins like this (a so-called docstring):
def sirkelsektor(r,theta):

Parameters
———- r : TYPE
DESCRIPTION.
theta : TYPE DESCRIPTION.
Returns
——- TYPE
DESCRIPTION.

Full this operate and check that it provides the anticipated reply
for r = 1, ? = zero, p, 2pr = 1, ? = zero, p, 2pr = 1, ? = zero, p, 2p. What occurs if somebody makes use of this characteristic however specifies the angle in levels as an alternative of radians? Can we get an error message?

——

You will write an executable Python program for each task, which you will then compile into a.py file and add. Additionally, please ship a printout of the outcomes of Workouts 1, 2, and Three.
1st Task The weierstrass.py script Weierstrass.py incorporates a operate w that’s required for this work; thus, obtain it and place it in the identical folder because the file you are about to submit. This is the place you’ll must program (in Python):

1. Draw a graph of the operate w on the interval [-2, 2]. Strive totally different num values in np.linspace to see how advantageous a division of the x-axis in np.linspace is required to point out sufficient info.

Then, write a operate named wderivert (x, h) that employs a technique for computing the by-product at each of the factors.

Published by
Medical
View all posts