Jamal Mesidor Newton Secant Method Mathematica Code-HW Math320

download Jamal Mesidor Newton Secant Method Mathematica Code-HW Math320

of 6

description

newton/secant method mathematica code from numerical methos class

Transcript of Jamal Mesidor Newton Secant Method Mathematica Code-HW Math320

  • NewtonRaphson@ x0_, max_D :=ModuleB8
  • Plot@f@xD, 8x, -5, 5
  • p0 = 0.0000000000000000, f@p0D =1.

    p1 = 0.5000000000000000, f@p0D =0.01134878145880891

    p= 0.5057395273712173,f@pD=0.01134878145880891

    2 p= 0.5346911095406560,f@2 pD=0.00947116374420509

    3 p= 0.5457466521293517,f@3 pD=0.002617255170712596

    4 p= 0.5541878772558704,f@4 pD=0.001133153989021973

    5 p= 0.5590501528340384,f@5 pD=0.0004141546717236766

    6 p= 0.5621529447902443,f@6 pD=0.0001613339470762365

    p =0.5621529447902443

    Dp =0.00310279

    f@pD =0.0000612722666615273

    NewtonError = 0.567143 - 0.5559645425958832

    0.0111785

    SecantError = 0.567143 - 0.5621529447902443

    0.00499006

    f@x_D := Log@x - 1D + Cos@x - 1D

    Plot @ f@xD, 8x, -5, 5

  • P1= 1.0460558073763590,f@P1D=-2.078961795238372

    P2= 1.1420075261956400,f@P2D=-0.961941356829404

    P3= 1.2814122543706730,f@P3D=-0.3072703918061856

    P4= 1.3752125652068680,f@P4D=-0.04983282895852758

    P5= 1.3968914012446590,f@P5D=-0.001825497071324955

    P6= 1.3977472256235330,f@P6D=-2.659228743651099 10-6

    p =1.397747225623533

    Dp =-+0.000855824

    f@pD =-2.659228743651099 10-6

    FindRoot@Log@x - 1D + Cos@x - 1D, 8x, 10

  • Plot@f@xD, 8x, -5, 5
  • p0 = 1.0000000000000000, f@p0D =-4.

    p1 = 3.0000000000000000, f@p0D =692.

    p= 1.0114942528735630,f@pD=692.

    2 p= 1.0219896114927700,f@2 pD=-3.67176441877633

    3 p= 1.1353784006454350,f@3 pD=-3.36069569018272

    4 p= 1.1143986026142000,f@4 pD=0.7629854624408345

    5 p= 1.1171060194827600,f@5 pD=-0.1130514787912595

    6 p= 1.1171816561283400,f@6 pD=-0.00307246504254266

    p =1.11718165612834

    Dp =0.0000756366

    f@pD =0.00001291702121619664

    NewtonError = 1.11718 - 1.117320727356156

    -0.000140727

    SecantError = 1.11718 - 1.11718165612834

    -1.65613 10-6

    6 Jamal_Mesidor_Newton_Secant_Method_HW_000-05-7204.nb