You are on page 1of 7

Carlos Alfredo Gonzalez Gutierrez

20092005026

Cdigo en Matlab para la Funcin

( )

( )

CON SERIES DE LEGENDRE Y MCLAURIN

LEGENDRE
>> syms x
>> f = sin(x);
>> L1=(3/2)*eval(int(f*x,x,-1,1))
L1 =
0.90350603681927
>> L2 = (7/2)*eval(int(f*(1/2)*(5*x^3-3*x),x,-1,1))
L2 =
-0.06304606781978
>> L3 = (11/16)*eval(int(f*(63*x^5-70*x^3+15*x),x,-1,1))
L3 =
0.00101817274424
>> x = 0:0.04:1
Columns 1 through 11
0 0.0400 0.0800 0.1200 0.1600 0.2000 0.2400
0.3600 0.4000
Columns 12 through 22
0.4400 0.4800 0.5200
0.8000 0.8400

0.5600

0.6000

0.6400

0.2800

0.6800

0.7200

0.3200

0.7600

Columns 23 through 26
0.8800 0.9200 0.9600 1.0000
>> a = 1;
>> while (a<=26)
L(a) = L1*x(a) + L2*((1/2)*(5*x(a)^3-3*x(a))) + L3*((1/8)*(63*x(a)^5-70*x(a)^3+15*x(a)));
a = a+1;
end
L=
Columns 1 through 6
0 0.03998871177124 0.07991350288859 0.11971055122470
0.15931623170528 0.19866721483570
Columns 7 through 12
0.23770056522746 0.27635384012476 0.31456518793107 0.35227344673560
0.38941824283991 0.42594008928442
Columns 13 through 18
0.46178048437493 0.49688201020921 0.53118843120348 0.56464479261900
0.59719751908861 0.62879451314320
Columns 19 through 24
0.65938525373836 0.68892089478082 0.71735436365506 0.74464045974979
0.77073595298455 0.79559968233622
Columns 25 through 26

Carlos Alfredo Gonzalez Gutierrez

20092005026

0.81919265436555 0.84147814174372
>> a = 1;
>> while (a<=26)
S(a) = sin(x(a));
a = a+1;
end
S=
Columns 1 through 6
0 0.03998933418663 0.07991469396917 0.11971220728892
0.15931820661425 0.19866933079506
Columns 7 through 12
0.23770262642713 0.27635564856411 0.31456656061612 0.35227423327509
0.38941834230865 0.42593946506600
Columns 13 through 18
0.46177917554148 0.49688013784374 0.53118619792088 0.56464247339504
0.59719544136239 0.62879302401847
Columns 19 through 24
0.65938467197147 0.68892144511055 0.71735609089952 0.74464311997086
0.77073887889897 0.79560162003637
Columns 25 through 26
0.81919156830100 0.84147098480790
>> E1 = S L
E1 =
1.0e-005 *
Columns 1 through 6
0 0.06224153918238 0.11910805806231 0.16560642226715
0.19749089620047 0.21159593592557
Columns 7 through 12
0.20611996753850 0.18084393489382 0.13726850491280 0.07865394887618
0.00994687364697 -0.06242184200089
Columns 13 through 18
-0.13088334489542 -0.18723654687247 -0.22332825935223 -0.23192239685388 0.20777262139671 -0.14891247356319
Columns 19 through 24
-0.05817668884411 0.05503297284548 0.17272444675642 0.26602210716486
0.29259144176397 0.19377001447829
Columns 25 through 26

Carlos Alfredo Gonzalez Gutierrez

20092005026

-0.10860645541788 -0.71569358279788
>> E1 = abs (E1)
E1 =
1.0e-005 *
Columns 1 through 6
0 0.06224153918238 0.11910805806231 0.16560642226715
0.19749089620047 0.21159593592557
Columns 7 through 12
0.20611996753850 0.18084393489382 0.13726850491280 0.07865394887618
0.00994687364697 0.06242184200089
Columns 13 through 18
0.13088334489542 0.18723654687247 0.22332825935223 0.23192239685388
0.20777262139671 0.14891247356319
Columns 19 through 24
0.05817668884411 0.05503297284548 0.17272444675642 0.26602210716486
0.29259144176397 0.19377001447829
Columns 25 through 26
0.10860645541788 0.71569358279788
>> sum = 0;
>> a = 1;
>> while(a<=26)
sum = sum + E1(a);
a = a+1;
end
sum =
4.423971276509842e-005
>> d = sum / length(E1)
d=
1.701527414042247e-006
MC LAURIN
>> M1 = 1;
>> M2 = -1/6;

Carlos Alfredo Gonzalez Gutierrez

20092005026

>> M3 = 1/120;
>> b = 1;
>> while (b<27)
M(b) = M1*x(b) + M2*(x(b)^3) + M3*(x(b)^5)
b = b +1;
end
M=
Columns 1 through 6
0 0.03998933418667 0.07991469397333 0.11971220736000
0.15931820714667 0.19866933333333
Columns 7 through 12
0.23770263552000 0.27635567530667 0.31456662869333 0.35227438848000
0.38941866666667 0.42594009685333
Columns 13 through 18
0.46178033664000 0.49688217002667 0.53118960981333 0.56464800000000
0.59720411818667 0.62880627797333
Columns 19 through 24
0.65940443136000 0.68895027114667 0.71739733333333 0.74470109952000
0.77081909930667 0.79571101269333
Columns 25 through 26
0.81933877248000 0.84166666666667
>> a = 1;
>> while (a<=26)
S(a) = sin(x(a));
a = a+1;
end
S=
Columns 1 through 6
0 0.03998933418663 0.07991469396917 0.11971220728892
0.15931820661425 0.19866933079506
Columns 7 through 12
0.23770262642713 0.27635564856411 0.31456656061612 0.35227423327509
0.38941834230865 0.42593946506600
Columns 13 through 18

Carlos Alfredo Gonzalez Gutierrez

20092005026

0.46177917554148 0.49688013784374 0.53118619792088 0.56464247339504


0.59719544136239 0.62879302401847
Columns 19 through 24
0.65938467197147 0.68892144511055 0.71735609089952 0.74464311997086
0.77073887889897 0.79560162003637
Columns 25 through 26
0.81919156830100 0.84147098480790
>> E2 = abs (S-M)
E2 =
1.0e-003 *
Columns 1 through 6
0 0.00000000003251 0.00000000416063 0.00000007108064
0.00000053242069 0.00000253827215
Columns 7 through 12
0.00000909286541 0.00002674255295 0.00006807721559 0.00015520491004
0.00032435801617 0.00063178733373
Columns 13 through 18
0.00116109851711 0.00203218292993 0.00341189244990 0.00552660496456
0.00867682427463 0.01325395486484
Columns 19 through 24
0.01975938852683 0.02882603611531 0.04124243381054 0.05797954914066
0.08022040769728 0.10939265696741
Columns 25 through 26
0.14720417900171 0.19568185877017
>> sum2 = 0;
>> b = 1;
>> while (b<27)
sum2 = sum2 + E2(b);
b = b+1;
end
>> sum2
sum2 =

Carlos Alfredo Gonzalez Gutierrez

7.155874768913981e-004
>> y = sum2/ length(E2);
>> y
y=
2.752259526505377e-005

20092005026

Carlos Alfredo Gonzalez Gutierrez

20092005026

TABLA DIFERENCIA

X
0
0.04000000000000
0.08000000000000
0.12000000000000
0.16000000000000
0.20000000000000
0.24000000000000
0.28000000000000
0.32000000000000
0.36000000000000
0.40000000000000
0.44000000000000
0.48000000000000
0.52000000000000
0.56000000000000
0.60000000000000
0.64000000000000
0.68000000000000
0.72000000000000
0.76000000000000
0.80000000000000
0.84000000000000
0.88000000000000
0.92000000000000
0.96000000000000
1.00000000000000

/ LEGENDRE Y MCLAURIN

L(Legendre)
0
0.03998871177124
0.07991350288859
0.11971055122470
0.15931623170528
0.19866721483570
0.23770056522746
0.27635384012476
0.31456518793107
0.35227344673560
0.38941824283991
0.42594008928442
0.46178048437493
0.49688201020921
0.53118843120348
0.56464479261900
0.59719751908861
0.62879451314320
0.65938525373836
0.68892089478082
0.71735436365506
0.74464045974979
0.77073595298455
0.79559968233622
0.81919265436555
0.84147814174372

M(Mac Laurin)
0
0.03998933418667
0.07991469397333
0.11971220736000
0.15931820714667
0.19866933333333
0.23770263552000
0.27635567530667
0.31456662869333
0.35227438848000
0.38941866666667
0.42594009685333
0.46178033664000
0.49688217002667
0.53118960981333
0.56464800000000
0.59720411818667
0.62880627797333
0.65940443136000
0.68895027114667
0.71739733333333
0.74470109952000
0.77081909930667
0.79571101269333
0.81933877248000
0.84166666666667

S(sen(x))
0
0.03998933418663
0.07991469396917
0.11971220728892
0.15931820661425
0.19866933079506
0.23770262642713
0.27635564856411
0.31456656061612
0.35227423327509
0.38941834230865
0.42593946506600
0.46177917554148
0.49688013784374
0.53118619792088
0.56464247339504
0.59719544136239
0.62879302401847
0.65938467197147
0.68892144511055
0.71735609089952
0.74464311997086
0.77073887889897
0.79560162003637
0.81919156830100
0.84147098480790

You might also like