Chem 302 Lab Assignment - PowerPoint PPT Presentation

1 / 55
About This Presentation
Title:

Chem 302 Lab Assignment

Description:

Chem 302 Lab Assignment. Tuesday 2:30 4:00. Colin. Chris M. Johnathan P. Craig. Jonathan E. Alex. Tuesday 4:00 5:30. Curtis. Matt. Chris L ... – PowerPoint PPT presentation

Number of Views:95
Avg rating:3.0/5.0
Slides: 56
Provided by: drdale1
Category:
Tags: assignment | chem | chrism | lab

less

Transcript and Presenter's Notes

Title: Chem 302 Lab Assignment


1
Chem 302 Lab Assignment
  • Tuesday 230 400ColinChris MJohnathan
    PCraigJonathan EAlex
  • Tuesday 400 530CurtisMattChris
    LJanetCoryKristen

2
Chem 302 - Math 252
  • Chapter 1Solutions of nonlinear equations

3
Roots of Nonlinear Equations
  • Many problems in chemistry involve nonlinear
    equations
  • Linear and quadratic equations are trivial, can
    be solved analytically
  • Cubic and higher order solve numerically
  • Present a overview of basic methods
  • Not a complete discussion

4
Successive Approximations
  • Simplest method
  • Want to solve f(x)0rearrange into the
    form xg(x)
  • Use as iteration formula xi1g(xi)
  • Use initial guess and iterate until self
    consistent

5
Successive Approximations
6
(No Transcript)
7
Successive Approximations
  • Second root

8
Successive Approximations
  • Second root

9
Successive Approximations
  • Different formula

Will find x2, will not find x1
Different formula different results No one
formula is best Slow to converge
10
Successive Approximations
  • How to find initial guesses?
  • Grid search

Course to start Get finer
11
Analysis of Convergence
  • Each stage of iteration xi1g(xi)
  • For convergence
  • True root
  • Intersection of two functions x g(x)

12
Analysis of Convergence
13
Analysis of Convergence
  • Four possibilities
  • Monotonic convergence
  • Oscillating convergence
  • Monotonic divergence
  • Oscillating divergence

14
Monotonic convergence
15
Oscillating convergence
16
Monotonic divergence
17
Oscillating divergence
18
Analysis of Convergence
  • Key is g?(x)
  • Mean Value Theorem
  • If g(x) and g?(x) are continuous on the interval
    a,b then there exists an e (alteltb) such that

19
Analysis of Convergence
20
Analysis of Convergence
If M lt 1 guaranteed to converge
Sufficient but not necessary
To converge LHS ? 0
21
Speed of Convergence
Taylor expansion about root
For xi
When close to convergence
  • Dominant term will be 1st nonzero derivative
  • Order of Convergence

22
Newton-Raphson Method
  • One of most common methods
  • Usually 2nd order convergence
  • Generally superior to simple iteration
  • Uses function and 1st derivative to predict root
    (assume f is linear)

23
Newton-Raphson Method
24
Newton-Raphson Method
  • Fairly robust
  • Need analytic expressions for f(x) and f'(x)
  • May be complicated or not available
  • Need to evaluate f(x) and f'(x) many times
  • Maximum efficiency
  • f'(x) close to zero will cause problems
  • Especially important for multiple roots
  • Need to checks in program
  • Value of f'(x)
  • Max iterations

25
Newton-Raphson Method
  • Test conditions

Convergence
26
Secant Method
  • NR but use numeric derivative
  • Need two points to start

27
False-Position Method
  • Similar to Secant Method
  • Uses two points (one on each side of root) (need
    search)
  • Find where function would be zero if linear
    between two points
  • During each iteration one point is held fixed
    (pivot), other is moved
  • More stable but slower than NR
  • If pivot far from root then slow
  • If pivot close to root then denominator can be
    small

28
False-Position Method
  • Algorithm
  • Pick xL xR (xL lt lt xR)
  • Evaluate
  • Calculate
  • Calculate
  • If then xM is the root
  • Replace xL or xR with xM (depends on sign of
    )

xM
xL
xR
Repeat
29
False-Position Method
30
Bisection Method
  • Same as FP Method but xM is average of xL xR
  • Drawbacks of both FP Bisection
  • Two initial guesses on opposite sides of root
  • Multiple or close roots a problem
  • f always same sign a problem
  • Round-off error as xM gets close to root
  • Secant, FP Bisection methods do not require
    analtyic expression of f'(x)

31
Roots of Polynomials
  • Want as efficient an algorithm as possible
  • Efficiency of operations
  • /
  • Power
  • Naive method (10 , 4 )
  • Most efficient method for polynomial of order m
    requires m additions and m multiplications
  • Nesting (Horners Method)

32
Horners Method
  • For polynomial of degree m
  • Divide by (x-r)
  • b0 is f(r)

33
Horners Method
m , m
34
Horners Method
1 is a root
35
Horners Method
2 is a root
36
Horners Method
  • If b0 0 (i.e. r is a root)
  • Have factored (x-r) from equation (i.e. reduced
    order, called deflating)
  • Continue to find roots of reduced equation

37
Horners Method
2 is a root (i.e. a double root of original
equation)
38
Birge-Vieta Method
  • NR method with f(x) and f'(x) evaluated using
    Horners method
  • Once a root is found, reduce order of polynomial

39
Birge-Vieta Method
40
Birge-Vieta Method
41
Birge-Vieta Method
42
Birge-Vieta Method
43
Birge-Vieta Method
44
Example
45
Example
  • NR
  • x0 ? 4.33 ? 3
  • x0 gt 4.33 ? 5
  • Third root?

Try it!!!
46
  • BV

47
Roots of Polynomials
  • What about complex roots?
  • Occur in pairs
  • Have form a ib a ib
  • Roots of quadratic equation f(x) x2 2ax
    a2 b2
  • BV method we removed factors of x r.
  • Quadratic can be solved analytically therefore
    best to remove quadratic factors

48
Lin-Bairstow Method
49
Lin-Bairstow Method
  • Iteration Scheme

50
Lin-Bairstow Method
  • Algorithm
  • m gt 3 determine quadratic roots, reduce order of
    problem by 2
  • m 3 determine linear root then quadratic roots
  • m 2 determine quadratic roots
  • m 1 determine linear root

51
  • // Lin Biarstow.cpp
  • include "stdafx.h"
  • include ltfstreamgt
  • include ltconio.hgt
  • include ltstdio.hgt
  • include ltmath.hgt
  • include ltstdlib.hgt
  • include ltstringgt
  • include ltdos.hgt
  • include ltiostreamgt
  • using namespace std
  • int _tmain(int argc, _TCHAR argv)
  • double t1e-8, a, b, c,u,v,du,dv,r1,r2,ep,f,d
  • int n,i
  • FILE logfile
  • anew doublen1
  • bnew doublen1
  • cnew doublen1
  • for(i0iltn1i)
  • coutltlt"\nInput coefficient a"ltltiltlt" "
  • cingtgtai
  • fprintf(logfile,"\nlf lfx",a0,a1)
  • for(i2iltn1i)fprintf(logfile,"
    lfxd",ai,i)
  • coutltlt"\n\nRoots of the polynomial are\n"
  • fprintf(logfile,"\n\nRoots are\n")
  • while (an0)n--
  • // make sure ngt3
  • while(ngt3)

52
  • b0a0ub1vb2
  • fc2c2-c1c3
  • if(f0)dudv1
  • elsedu(b0c3-b1c2)/fdv(c1b1
    -c2b0)/f
  • udu
  • vdv
  • epsqrt(dududvdv)
  • duu4v
  • if(dlt0) //complex roots
  • r1u/2r2sqrt(-d)/2
  • coutltltr1ltlt" i"ltltr2ltltendl
  • coutltltr1ltlt" - i"ltltr2ltltendl
  • fprintf(logfile,"lf ilf\nlf -
    ilf\n",r1,r2,r1,r2)
  • else // real roots
  • if(n3)
  • u0
  • bncnanep1
  • while(epgtt)
  • for(in-1igt0i--)
  • biaiubi1
  • cibiuci1
  • b0a0ub1
  • if(c10)du1
  • else du-b0/c1
  • udu
  • epsqrt(dudu)
  • coutltltultltendl
  • fprintf(logfile,"lf\n",u)
  • n--

53
  • if(dlt0) //complex roots
  • r1u/2r2sqrt(-d)/2
  • coutltltr1ltlt" i"ltltr2ltltendl
  • coutltltr1ltlt" - i"ltltr2ltltendl
  • fprintf(logfile,"lf ilf\nlf -
    ilf\n",r1,r2,r1,r2)
  • else
  • r1u/2sqrt(d)/2
  • r2u/2-sqrt(d)/2
  • coutltltr1ltltendl
  • coutltltr2ltltendl
  • fprintf(logfile,"lf\nlf\n",r1,r2)
  • else if(n1)
  • r1-a0/a1

54
(No Transcript)
55
  • Roots of the polynomial
  • -130.000000 120.000000x -2.000000x2
    -9.000000x3 1.000000x4
  • Roots are
  • 3.972068
  • -3.600135
  • 7.399477
  • 1.228589
Write a Comment
User Comments (0)
About PowerShow.com