Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

11

description

Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

Transcript of Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    1/11

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    2/11

    c)octave-3.6.1.exe:1> x=[2 9 16]

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    3/11

    x =

    2 9 16

    octave-3.6.1.exe:2> y=[2^(1/2)*17^(1/2) 3*17^(1/2) 4*17^(1/2)]

    y =

    5.8310 12.3693 16.4924

    octave-3.6.1.exe:3> c=polyfit(x,y,2)

    c =

    -0.024646 1.205153 3.519229

    octave-3.6.1.exe:4> P2=polyout(c)

    P2 = -0.024646*s^2 + 1.2052*s^1 + 3.5192

    octave-3.6.1.exe:5> P=polyval(c,x)

    P =

    5.8310 12.3693 16.4924

    octave-3.6.1.exe:6> Ps=polyval(c,12)

    Ps = 14.432

    octave-3.6.1.exe:7> erP=(14.2828-14.4321)*100/14.2828

    erP = -1.0453

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    4/11

    d) erL=erP=-1,0453%

    e) octave-3.6.1.exe:1> x=2:0.1:16;

    octave-3.6.1.exe:2> N2=-0.0246*x.^2+1.2046*x. 1+3.5202;

    octave-3.6.1.exe:3> L2=-0.0246*x.^2+1.2052*x.^1+3.5192;

    octave-3.6.1.exe:4> P2=-0.0246*x.^2+1.2052*x.^1+3.5192;

    octave-3.6.1.exe:5> f=sqrt(17)*x.^(1/2);

    octave-3.6.1.exe:6> plot(x,f,"o1",x,L2,"o2",x,N2,"*4",x,P2,"+2"),grid("on")

    Problema 2

    octave-3.2.4.exe:1> x=[1 2 3 4 5]

    x =

    1 2 3 4 5

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    5/11

    octave-3.2.4.exe:2> y=[-17*2 17*2 17 17/10 17*10]

    y =

    -34.0000 34.0000 17.0000 1.7000 170.0000

    octave-3.2.4.exe:3> yi=spline(x,y)

    yi =

    {

    x =

    1

    2

    3

    4

    5

    P =

    10.4833 -73.9500 131.4667 -34.0000

    10.4833 -42.5000 15.0167 34.0000

    34.2833 -11.0500 -38.5333 17.0000

    34.2833 91.8000 42.2167 1.7000

    n = 4

    k = 4

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    6/11

    d = 1

    }

    octave-3.2.4.exe:4> valinterp1=ppval(yi,(2.6))

    valinterp1 = 29.974

    octave-3.2.4.exe:5> valinterp2=ppval(yi,(4.2))

    valinterp2 = 14.090

    octave-3.2.4.exe:6> x=[1 2 3 4]

    x =

    1 2 3 4

    octave-3.2.4.exe:7> y=[-17*2 17*2 17 17/10]

    y =

    -34.0000 34.0000 17.0000 1.7000

    octave-3.2.4.exe:8> p=polyfit(x,y,3)

    p =

    14.450 -129.200 354.450 -273.700

    octave-3.2.4.exe:9> pp=polyout(p)

    pp = 14.45*s^3 - 129.2*s^2 + 354.45*s^1 - 273.7

    octave-3.2.4.exe:10> x=1:0.1:4;

    octave-3.2.4.exe:11> y=14.45*x.^3-129.2*x.^2+354.45*x. 1-273.7;

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    7/11

    octave-3.2.4.exe:12> yi=spline(x,y,x)

    yi =

    Columns 1 through 7:

    -34.00000 -20.90405 -9.43840 0.48365 8.94880 16.04375 21.85520

    Columns 8 through 14:

    26.46985 29.97440 32.45555 34.00000 34.69445 34.62560 33.88015

    Columns 15 through 21:

    32.54480 30.70625 28.45120 25.86635 23.03840 20.05405 17.00000

    Columns 22 through 28:

    13.96295 11.02960 8.28665 5.82080 3.71875 2.06720 0.95285

    Columns 29 through 31:

    0.46240 0.68255 1.70000

    octave-3.2.4.exe:13> plot(x,yi),grid("on")

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    8/11

    Problema 3

    octave-3.6.1.exe:1> j=5*((17*((-5/sqrt(3)+6)^2+1))/(1+log(-5/sqrt(3)+6))+(17*((5/sqrt(3)+6)^2+1))/(1+log(5/sqrt(3)+6)))

    j = 2560.2

    octave-3.6.1.exe:2> er1=(17*150.8745-j)/(17*150.8745)*100

    er1 = 0.18297

    octave-3.6.1.exe:3> x=[1 6 11]

    x =

    1 6 11

    octave-3.6.1.exe:4> function y=f(x)

    > y=17*(x^2+1)/(1+log(x))

    > endfunction

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    9/11

    octave-3.6.1.exe:5> format long

    octave-3.6.1.exe:6> i=quad("f",1,11)

    i = 2564.86654798786

    octave-3.6.1.exe:7> er2=(17*150.8745-i)/(17*150.8745)*100

    er2 = -1.87096911061579e-006

    octave-3.6.1.exe:8>y=[17*(1^2+1)/(1+log(2)) 17*(6^2+1)/(1+log(6)) 17*(11^2+1)/(1+log(11))]

    y =

    20.0809477110878 225.3059430560197 610.3778467227263

    octave-3.6.1.exe:9> k=5/3*(20.0809+4*225.3059+610.3778)

    k = 2552.80383333333

    octave-3.6.1.exe:10> er3=(17*150.8745-k)/(17*150.8745)*100

    er3 = 0.470303880013509

    Problema 4

    4.1)

    octave-3.6.1.exe:1> x=0:2:24;

    y=[17*65 17*67 17*79 17*97 17*120 17*143 17*164 17*180 17*189 17*187 17*172 17*140

    17*89]

    y =

    Columns 1 through 11:

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    10/11

    1105 1139 1343 1649 2040 2431 2788 3060 3213 3179 2924

    Columns 12 and 13:

    2380 1513

    octave-3.6.1.exe:2> c=polyfit(x,y,3)

    c =

    -1.0185 26.3969 -29.7348 1103.4588

    octave-3.6.1.exe:3> P=polyout(c)

    P = -1.0185*s^3 + 26.397*s^2 - 29.735*s^1 + 1103.5

    octave-3.6.1.exe:4> F=polyval(c,x)

    F =

    Columns 1 through 8:

    1103.5 1141.4 1341.7 1655.3 2033.5 2427.3 2787.8 3066.1

    Columns 9 through 13:

    4.2)

    octave-3.6.1.exe:6> trapz(x,y)

    ans = 54910

    octave-3.6.1.exe:7> sum(-1.0185*x.^3 + 26.397*x.^2 -29.735*x.^1 + 1103.5)

  • 5/25/2018 Predeleanu Dumitru, 2213 C, Tema 1 Metode Numerice.

    11/11

    ans = 2.8767e+004

    3213.4 3180.7 2919.2 2380.0 1514.2

    4.3)

    octave-3.6.1.exe:8 > grid("on"),plot(x,y,"-*3;graficul zilnic de sarcina(tabel);"), hold("on")

    octave-3.6.1.exe:9> plot(x,-1.0185*x.^3 + 26.397*x.^2 -29.735*x.^1 + 1103.5,"-o1;functia P=P(t)(punctul

    1) ;")