• Keine Ergebnisse gefunden

Worksheet 11: Root Finding July 10, 2017

N/A
N/A
Protected

Academic year: 2021

Aktie "Worksheet 11: Root Finding July 10, 2017"

Copied!
1
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Physik auf dem Computer SS 2017

Worksheet 11: Root Finding

July 10, 2017

General Remarks

• The deadline for handing in the worksheets is Monday, July 17th, 2017, 12:00 noon.

• This is a short worksheet, for which you can achieve a maximum of 6 points.

• To hand in your solutions, send an email to

Michael Kuron mkuron@icp.uni-stuttgart.de (all groups!)

• Please try to only hand in a single file that contains your program code for all tasks. If you are asked to answer questions, you should do so in a comment in your code file. If you are asked for graphs or figures, it is sufficient if your code generates them. You may as well hand in a separate PDF document with all your answers, graphs and equations.

• The worksheets are to be solved in groups of two or three people.

Task 11.1: Root Finding (6 points)

11.1.1 (3 points) Implement three Python functions that find the root of a function:

newton(f, fp, x0) , which uses Newton’s method to find the root of the function f , where fp is the derivative of the function and x0 is the initial value of the iteration.

secant(f, x0, x1) , which uses the secant method to find the root of the function f , where x0 and x1 are the initial values of the iteration.

regula_falsi(f, x0, x1) , which uses the regula falsi method to find the root of the func- tion f in the interval [ x0 , x1 ].

The methods should terminate when they have reached an accuracy of 10

−16

. The accuracy of a given iteration is the absolute difference to the previous iteration in Newton’s method and the absolute difference between the two guesses for the secant method. For the regula falsi method, the accuracy has to be determined as abs(f(p)) , where p is the newly determined point in the current iteration.

11.1.2 (1 point) Use the functions to compute the root of the following functions:

f (x) = x

2

− 1 (initial guess for Newton’s method x

0

= 3, initial interval for the secant method and regula falsi [0, 3])

g(x) = cos(x) (initial guess for Newton’s method x

0

= 2, initial interval for the secant method and regula falsi [0, 2])

11.1.3 (1 point) Extend the Python functions from the previous task such that they record the reached accuracy in every iteration. Create a plot with logarithmic scale on the y-axis that shows the accuracy of the three methods versus the iteration number for both cases.

11.1.4 (1 point) As before, try to use Newton’s method to compute the root of g(x) = cos(x), but this time start with an initial value of x

0

= 0. Then, use the secant method to compute the root of g(x), but start the method with initial values of x

0

= −1 and x

1

= 1. What is happening? Why do the methods fail?

1

Referenzen

ÄHNLICHE DOKUMENTE

b) Zeigen Sie, dass der Hamilton-Operator H mit dem Operator σ ·P vertauscht, wobei P der Impulsoperator ist und σ die Pauli Spinoperatoren im Raum von vier Komponentenspinoren

A shRNA-mediated knockdown of Copine 6 in primary hippocampal culture increases the number of dendritic spines and influences their maintenance upon changes in neuronal activity..

[r]

[r]

In the practical part follows a statistical analysis of the interaction of the Determination, stylistic and communicative function by the use of articles in nominal and

In the event of a Local or Asian financial crisis our findings suggests that Malaysia will be the stock index affected the most as it is highly correlated

Finalmente, dado que la distribución de los residuos de la ecuación de corto plazo es unimodal y no presenta mayor masa de probabilidad en sus colas (o valores extremos),

Second, because paid apps are important to smartphone users, using paid apps for free is a main reason for jailbreaking, a reason more decisive among Android users than Apple