Summary week 8 - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

Summary week 8

Description:

Summary week 8. Traveling salesman problem. Optimize ... e.g. grenade trajectory. boundary: initial speed, final destination. required: angle of canon ... – PowerPoint PPT presentation

Number of Views:102
Avg rating:3.0/5.0
Slides: 33
Provided by: bul8
Category:
Tags: grenade | summary | week

less

Transcript and Presenter's Notes

Title: Summary week 8


1
Summary week 8
  • Traveling salesman problem
  • Optimize algorithms number of steps, sigma,
    different strategies
  • Poor algorithm 160Mm (taking closest city)
  • Good algorithm 130 Mm
  • Shortest path on the website

2
Final results
  • 3 distances lt 128000 km in 800 seconds
  • 79 configurations lt 129500 km

3
Summary Week 8
  • Integration
  • closed form boundaries included
  • open form less precise (1 order lower in number
    of steps/derivative)
  • redefine integration variables in case of
    improper integrals.
  • Higher accuracy by weighting the function values
    differently
  • Basic 1st order accuracy
  • Simpsons, adaptive stepsize, 4rd order
    (1/3,4/3,2/3,4/3,)

4
Summary Week 8
  • Romberg cancel even powers by doubling the
    number of grid points rapid convergation
  • Euler-MacLaurin Summation
  • Open formulas triple number of points
  • Gaussian Quadrature
  • Freedom to choose abscissa as well as weight
  • Fastest convergation, typically within 20
    function calls)

5
(16) Ordinary Differential Eqs.
  • ordinary differential equations sets of
    first-order differential equations.
  • new variables typically derivatives of each
    other. Generic diff. equation becomes coupled set
    of first order diff. eq.

6
Example
  • Suppose you want to calculate trajectories from a
    testmass that is on a spring, attached to a
    string
  • mass m, string length R0, radius r, uncompressed
    spring length l0, angles theta and phi.
  • There are nine dependent variables and 1
    independent (the time)

O
z
7
variables, equations
  • coordinates
  • velocities
  • accelerations

8
Boundary conditions
  • Crucial boundary conditions.
  • simple case variables have certain values at
    given points.
  • complicated non-linear algebraic relations among
    the variables.
  • initial value problems
  • yi specified at xs
  • solution required at (sets of) xf
  • two-point boundary value problems
  • boundary conditions at more values of x
  • typically, some at xs, remainder at xf
  • e.g. grenade trajectory
  • boundary initial speed, final destination
  • required angle of canon

9
Initial-value boundary problems
  • Initial-value boundary problems
  • Runge-Kutta
  • Bulirsch-Stoer
  • predictor-corrector
  • Two-point boundary problems
  • shooting
  • relaxation

10
Runge-Kutta
  • step from xi to xf in small steps h
  • Taylor expansion in series of steps
  • one step differentials specified at beginning of
    step. O(h2) accuracy. (Eulers method)
  • Better calculate derivative at midpoint

11
midpoint- Runge Kutta
12
Fourth-order Runge-Kutta
fourth-order RK superior to midpoint if h can
be chosen twice as big.
13
Runge-Kutta
  • quite robust. In NR supply function derivs() to
    calculate the right-hand side, as well as the
    derivatives at the initial step.
  • Adaptive stepsize control precision of result
  • overhead 11/8 calculations

14
Embedded Runge-Kutta
  • Alternative fifth-order RK requires 6 function
    evaluations. However, these same six evaluations
    can be used to make a 4th-order extrapolation as
    well. This then serves as error estimate
  • Values for a,b,c from Cash and Karp
  • stepsize tune

15
Modified midpoint method
  • advance from x to xH with n substeps hH/n.
    Right-hand side evaluations n1
  • midpoint method for intermediate z. One
    derivative per intermediate step, instead of 2
    for second-order RK. Error contains only even
    powers of h

16
Bulirsch-Stoer
  • modified midpoint fourth-order accuracy is
    obtained by
  • Richardson extrapolation (Bulirsh-Stoer) a la
    Romberg integration. Cancel higher orders in
    error, fine when ODEs are smooth (Else use
    Runge-Kutta with adaptive stepsize).
  • consider final answer as analytical function of
    parameter (stepsize h), probe it with some values
    h, fit the result for h-gt0
  • use rational function extrapolation
  • even error in powers of h

17
Bulirsch-Stoer
18
Stiff sets of equations
  • Stiffness two or more very different scales.
  • requires very small stepsize hltlt1/1000. Also for
    intermediate values!

19
Stiff sets of equations
  • Stability at a risk. Cure implicit differencing.
  • Explicit
  • Unstable if hgt2/c.
  • Implicit calculate y at right-hand side
  • Stable yn1 -gt 0 for h-gtinf.

20
Implicit differencing
  • Generalize for sets of equations
  • This only goes to zero if largest eigenvalue of
    (1-Ch) smaller than 1.
  • Implicit differencing
  • Always stable (for eigenvalues larger than one)
    but requires matrix inversion.

21
Implicit differencing
  • In general matrix C contains functions of y
  • This is the semi-implicit Euler method.
    Generalizations
  • Runge-Kutta like Kaps-Rentrop methods
  • Bulirsch-Stoer like Bader and Deuflhard

22
Bader-Deuflhard
  • Implicit form of midpoint rule
  • use with the semi-implicit Euler step and a
    special initial and final step, this series again
    only involves even powers of h in the error.
    Method NRsimpr()

23
exercise
24
Two-point boundary value problems
  • Obviously, harder to obtain result in this case
  • Shooting method choose starting values at one
    boundary, guess the free parameters. Vary free
    parameters until the boundary eqs. at the second
    point are satisfied.
  • Relaxation Replace the diff. equations by
    finite-difference equations on a mesh of points.
    Choose (arbitrary) parameters on each mesh point
    and gradually try to decrease the discrepancies.

25
Shooting
  • Starting at x1, there are N-n1n2 free
    parameters. Write method that calculates the n1
    parameters for an arbitrary vector V with n2
    components (V spans space of possible solutions)
  • calculate y at x2, e.g. with Bulirsch-Stoer.
  • define the difference
  • Newton-Raphson

26
  • Shooting requires n21 integrations per trial.
    For linear problems only 1 trial needed. A
    second round may clean up result. Requires a
    function
  • (load()) to calculate the initial values of y,
    given n2 free parameters,
  • (score()) to calculate difference F,
  • starting vector v(0..n2-1)
  • function derivs to calculate the ODE integration.

27
Shooting to midpoint
  • Alternatively, one can shoot from x1 and x2 to a
    common midpoint.
  • more complicated difference depends on 2
    vectors, with n1 and n2 parameters.
  • preferable when endpoints are singular one can
    integrate away from it but not to it.

28
Relaxation methods
  • Replace ordinary differential equations by
    finite-difference equations
  • M meshpoints, N equations NM parameters.
    Newton-Raphson NMNM matrix. However it is in
    block-diagonal form.
  • Midpoints k coupled equations between k and k-1,
    2N parameters-gt N(M-1) parameters specified.
    remaining N parameters come from boundaries.
    Choose last n1 parameters at 0, first at M-1

29
Relaxation
  • initial guess yj,k. Calculate difference
  • NM-1 relations for M points and N variables.
  • remaining N relations from boundary
  • E0 B(x0,y0), EM-1 B(xM-1 ,yM-1)
  • difference delta write in matrix form
  • matrix has following form

30
relaxation, block diagonal matrix
5 variables 4 mesh points 3 boundarycond, at x0,
2 boundarycond at x3
31
relaxation, gaussian elimination
target form. Can be obtained by block by
block diagonalization. MN2N steps.
32
Relaxation
  • Automated calculation of mesh points possible
  • advantage for singular points.
Write a Comment
User Comments (0)
About PowerShow.com