Académique Documents
Professionnel Documents
Culture Documents
h representa la base de cada trapecio, viene dada por (b-a)/n siendo n el nmero de trapecios. A
ms trapecios, mejor aproximacin.
La extrapolacin de Richardson deduce a partir del error de la de los trapecios una mejor
aproximacin, dada por:
(TV es la mejor aproximacin, AVh/2 la aproximacin con 2n trapecios y AVh con n trapecios.
Es decir, a partir de 2 aproximaciones con trapecios optiene una mejor. )
La integracin de Romberg simplemente optiene ms aproximaciones a partir de otras
aproximaciones, como se ve en este esquema:
Considerando las nuevas generaciones de aproximaciones del mtodo de romberg como nmero de
iteracciones, para tener 10 necesitaremos calcular 10 aproximaciones por trapecios con:
n=1, n=2, n=22, n=23,.. n=210
A partir de estos 10 trapecios vamos calculando nuevas aproximaciones hasta que quede slo 1.
Python:
(hay una foto del script completo al final)
Importamos numpy y matplotlib, numpy sirve entre otras cosas para calcular funciones
como seno y coseno y construir arrays eficientes y fciles de operar. matplotlib es para
graficar funciones/puntos.
Ahora definimos una funcin que devuelva las funciones del enunciado:
C y S van a contener las aproximaciones calculadas, con el for metemos los valores en ellas y
con plot las representamos. Tambin definimos el intervalo I
1)2)
Ejecutamos el programa y nos da:
C: w=0
Iteraccion 1
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
Iteraccion 2:
[ 0. 0. 0. 0. 0. 0. 0. 0. 0.]
Iteraccion 3:
[ 0. 0. 0. 0. 0. 0. 0. 0.]
Iteraccion 4:
[ 0. 0. 0. 0. 0. 0. 0.]
Iteraccion 5:
[ 0. 0. 0. 0. 0. 0.]
Iteraccion 6:
[ 0. 0. 0. 0. 0.]
Iteraccion 7:
[ 0. 0. 0. 0.]
Iteraccion 8:
[ 0. 0. 0.]
Iteraccion 9:
[ 0. 0.]
Iteraccion 10:
[ 0.]
(Como era de esperar) la integral de 0 a 0 es F(0)-F(0) = 0
C: w=1
Iteraccion 1
[ 0.78893305 0.78465225 0.78233298 0.78112828 0.78051462 0.78020495
0.78004941 0.77997147 0.77993245 0.77991293]
Iteraccion 2:
[ 0.78322531 0.7815599 0.78072671 0.78031006 0.78010173 0.77999757
0.77994548 0.77991944 0.77990642]
Iteraccion 3:
[ 0.78100476 0.78044898 0.78017118 0.78003229 0.77996284 0.77992812
0.77991076 0.77990208]
Iteraccion 4:
[ 0.78026373 0.78007858 0.77998599 0.7799397 0.77991655 0.77990497
0.77989919]
Iteraccion 5:
[ 0.78001686 0.77995513 0.77992426 0.77990883 0.77990112 0.77989726]
Iteraccion 6:
[ 0.77993455 0.77991398 0.77990369 0.77989854 0.77989597]
Iteraccion 7:
[ 0.77990712 0.77990026 0.77989683 0.77989512]
Iteraccion 8:
[ 0.77989797 0.77989569 0.77989454]
Iteraccion 9:
[ 0.77989492 0.77989416]
Iteraccion 10:
[ 0.77989391]
C: w=2
Iteraccion 1
[ 0.46902545 0.47835111 0.48326568 0.48575494 0.4870036 0.48762843
0.48794091 0.48809716 0.48817528 0.48821434]
Iteraccion 2:
[ 0.48145966 0.48490388 0.4865847 0.48741982 0.48783671 0.48804507
0.48814924 0.48820132 0.48822736]
Iteraccion 3:
[ 0.48605195 0.48714497 0.48769819 0.48797567 0.48811452 0.48818396
0.48821868 0.48823604]
Iteraccion 4:
[ 0.48750931 0.4878826 0.48806816 0.48816081 0.48820711 0.48823026
0.48824183]
Iteraccion 5:
[ 0.48800702 0.48813002 0.48819169 0.48822254 0.48823797 0.48824569]
Iteraccion 6:
[ 0.48817102 0.48821224 0.48823283 0.48824312 0.48824826]
Iteraccion 7:
[ 0.48822598 0.48823969 0.48824655 0.48824998]
Iteraccion 8:
[ 0.48824426 0.48824883 0.48825112]
Iteraccion 9:
[ 0.48825036 0.48825188]
Iteraccion 10:
[ 0.48825239]
C: w=3
Iteraccion 1
[ 0.61075268 0.61427125 0.61159343 0.6090628 0.60749369 0.60663276
0.60618315 0.60595357 0.60583758 0.60577928]
Iteraccion 2:
[ 0.6154441 0.61070083 0.60821925 0.60697066 0.60634578 0.60603329
0.60587704 0.60579891 0.60575985]
Iteraccion 3:
[ 0.60911973 0.60739206 0.60655446 0.60613748 0.60592913 0.60582496
0.60577287 0.60574683]
Iteraccion 4:
[ 0.60681617 0.60627526 0.60599849 0.60585967 0.60579023 0.60575551
0.60573815]
Iteraccion 5:
[ 0.60609495 0.60590623 0.6058134 0.60576709 0.60574394 0.60573236]
Iteraccion 6:
[ 0.60584333 0.60578245 0.60575165 0.60573622 0.60572851]
Iteraccion 7:
[ 0.60576216 0.60574138 0.60573108 0.60572593]
Iteraccion 8:
[ 0.60573445 0.60572764 0.60572422]
Iteraccion 9:
[ 0.60572537 0.60572308]
Iteraccion 10:
[ 0.60572231]
C: w=4
Iteraccion 1
[ 0.48155437 0.48150098 0.4888173 0.49347522 0.49593219 0.4971768
0.49780113 0.49811355 0.49826978 0.49834791]
Iteraccion 2:
[ 0.48148319 0.49125607 0.49502785 0.49675119 0.49759167 0.49800924
0.49821768 0.49832186 0.49837395]
Iteraccion 3:
[ 0.4945137 0.49628512 0.49732563 0.49787184 0.49814843 0.49828717
0.49835659 0.49839131]
Iteraccion 4:
[ 0.49687559 0.49767247 0.49805391 0.49824062 0.49833341 0.49837973
0.49840288]
Iteraccion 5:
[ 0.49793809 0.49818105 0.49830286 0.49836434 0.49839517 0.4984106 ]
Iteraccion 6:
[ 0.49826204 0.49834346 0.49838484 0.49840545 0.49841574]
Iteraccion 7:
[ 0.49837061 0.49839863 0.49841232 0.49841918]
Iteraccion 8:
[ 0.49840797 0.49841689 0.49842146]
Iteraccion 9:
[ 0.49841986 0.49842298]
Iteraccion 10:
[ 0.49842402]
C: w=5
Iteraccion 1
[ 0.52511449 0.56065844 0.5687187 0.56800001 0.566284 0.56507551
0.56438288 0.56401442 0.56382465 0.56372838]
Iteraccion 2:
[ 0.57250642 0.57140546 0.56776045 0.565712 0.56467268 0.56415201
0.5638916 0.5637614 0.56369629]
Iteraccion 3:
[ 0.57103847 0.56654545 0.56502918 0.56432624 0.56397845 0.5638048
0.56371799 0.56367459]
Iteraccion 4:
[ 0.56504777 0.56452376 0.56409192 0.56386252 0.56374692 0.56368906
0.56366012]
Iteraccion 5:
[ 0.5643491 0.56394797 0.56378606 0.56370838 0.56366977 0.56365048]
Iteraccion 6:
[ 0.56381426 0.56373209 0.56368249 0.5636569 0.56364405]
Iteraccion 7:
[ 0.5637047 0.56366596 0.56364837 0.56363976]
Iteraccion 8:
[ 0.56365305 0.5636425 0.5636369 ]
Iteraccion 9:
[ 0.56363899 0.56363503]
Iteraccion 10:
[ 0.56363371]
S: w=0
Iteraccion 1
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
Iteraccion 2:
[ 0. 0. 0. 0. 0. 0. 0. 0. 0.]
Iteraccion 3:
[ 0. 0. 0. 0. 0. 0. 0. 0.]
Iteraccion 4:
[ 0. 0. 0. 0. 0. 0. 0.]
Iteraccion 5:
[ 0. 0. 0. 0. 0. 0.]
Iteraccion 6:
[ 0. 0. 0. 0. 0.]
Iteraccion 7:
[ 0. 0. 0. 0.]
Iteraccion 8:
[ 0. 0. 0.]
Iteraccion 9:
[ 0. 0.]
Iteraccion 10:
[ 0.]
S: w=1
Iteraccion 1
[ 0.41828337 0.4282622 0.43325953 0.4357592 0.43700915 0.43763415
0.43794665 0.4381029 0.43818102 0.43822008]
Iteraccion 2:
[ 0.43158848 0.43492531 0.43659242 0.43742581 0.43784248 0.43805081
0.43815498 0.43820706 0.43823311]
Iteraccion 3:
[ 0.43603758 0.43714812 0.4377036 0.43798137 0.43812026 0.4381897
0.43822443 0.43824179]
Iteraccion 4:
[ 0.4375183 0.43788876 0.43807396 0.43816655 0.43821285 0.438236
0.43824757]
Iteraccion 5:
[ 0.43801225 0.43813569 0.43819742 0.43822828 0.43824372 0.43825143]
Iteraccion 6:
[ 0.43817684 0.43821799 0.43823857 0.43824886 0.438254 ]
Iteraccion 7:
[ 0.43823171 0.43824543 0.43825229 0.43825572]
Iteraccion 8:
[ 0.43825 0.43825457 0.43825686]
Iteraccion 9:
[ 0.4382561 0.43825762]
Iteraccion 10:
[ 0.43825813]
S: w=2
Iteraccion 1
[ 0.35104447 0.34534148 0.34389879 0.34353662 0.34344593 0.34342324
0.34341757 0.34341615 0.3434158 0.34341571]
Iteraccion 2:
[ 0.34344048 0.3434179 0.3434159 0.3434157 0.34341568 0.34341568
0.34341568 0.34341568 0.34341568]
Iteraccion 3:
[ 0.34341037 0.34341523 0.34341564 0.34341567 0.34341568 0.34341568
0.34341568 0.34341568]
Iteraccion 4:
[ 0.34341685 0.34341577 0.34341569 0.34341568 0.34341568 0.34341568
0.34341568]
Iteraccion 5:
[ 0.34341541 0.34341566 0.34341568 0.34341568 0.34341568 0.34341568]
Iteraccion 6:
[ 0.34341574 0.34341568 0.34341568 0.34341568 0.34341568]
Iteraccion 7:
[ 0.34341566 0.34341568 0.34341568 0.34341568]
Iteraccion 8:
[ 0.34341568 0.34341568 0.34341568]
Iteraccion 9:
[ 0.34341568 0.34341568]
Iteraccion 10:
[ 0.34341568]
S: w=3
Iteraccion 1
[ 0.44207215 0.4670516 0.48140613 0.48882468 0.49256446 0.49443818
0.49537552 0.49584425 0.49607862 0.49619581]
Iteraccion 2:
[ 0.47537808 0.48619098 0.49129753 0.49381105 0.49506276 0.49568797
0.4960005 0.49615675 0.49623487]
Iteraccion 3:
[ 0.48979527 0.49299971 0.4946489 0.49547999 0.49589637 0.49610467
0.49620883 0.49626092]
Iteraccion 4:
[ 0.49406786 0.49519863 0.49575702 0.49603517 0.4961741 0.49624355
0.49627828]
Iteraccion 5:
[ 0.49557555 0.49594315 0.49612788 0.49622042 0.4962667 0.49628985]
Iteraccion 6:
[ 0.49606569 0.49618946 0.49625126 0.49628213 0.49629757]
Iteraccion 7:
[ 0.49623072 0.49627186 0.49629242 0.49630271]
Iteraccion 8:
[ 0.49628557 0.49629928 0.49630614]
Iteraccion 9:
[ 0.49630385 0.49630843]
Iteraccion 10:
[ 0.49630995]
S: w=4
Iteraccion 1
[ 0.4749363 0.4354877 0.42435309 0.42148158 0.42075768 0.42057627
0.42053089 0.42051954 0.4205167 0.42051599]
Iteraccion 2:
[ 0.42233816 0.42064155 0.42052441 0.42051638 0.4205158 0.42051576
0.42051575 0.42051575 0.42051575]
Iteraccion 3:
[ 0.42007602 0.42048536 0.4205137 0.42051561 0.42051574 0.42051575
0.42051575 0.42051575]
Iteraccion 4:
[ 0.42062181 0.42052315 0.42051625 0.42051579 0.42051576 0.42051575
0.42051575]
Iteraccion 5:
[ 0.42049026 0.42051395 0.42051563 0.42051575 0.42051575 0.42051575]
Iteraccion 6:
[ 0.42052184 0.4205162 0.42051578 0.42051576 0.42051575]
Iteraccion 7:
[ 0.42051432 0.42051565 0.42051575 0.42051575]
Iteraccion 8:
[ 0.42051609 0.42051578 0.42051576]
Iteraccion 9:
[ 0.42051568 0.42051575]
Iteraccion 10:
[ 0.42051577]
S: w=5
Iteraccion 1
[ 0.46291346 0.45833814 0.47537779 0.48684123 0.49296017 0.49606873
0.49762918 0.49841017 0.49880076 0.49899607]
Iteraccion 2:
[ 0.45681303 0.48105767 0.49066238 0.49499982 0.49710492 0.49814932
0.4986705 0.49893096 0.49906117]
Iteraccion 3:
[ 0.48913922 0.49386395 0.49644563 0.49780662 0.49849746 0.49884422
0.49901778 0.49910458]
Iteraccion 4:
[ 0.49543886 0.49730619 0.49826028 0.49872774 0.49895981 0.49907563
0.49913351]
Iteraccion 5:
[ 0.49792863 0.49857831 0.49888356 0.49903717 0.49911424 0.4991528 ]
Iteraccion 6:
[ 0.49879487 0.4989853 0.49908838 0.49913992 0.49916566]
Iteraccion 7:
[ 0.49904878 0.49912274 0.4991571 0.49917424]
Iteraccion 8:
[ 0.49914739 0.49916856 0.49917995]
Iteraccion 9:
[ 0.49917562 0.49918375]
Iteraccion 10:
[ 0.49918645]
Parece que converge hacia una cierta forma, si aumentamos el nmero de puntos:
w=6,w=7... w=9
para ello en vez de for i in range(0,6) ponemos range(0,10)
(tambin eliminiamos los print para que vaya ms rpido)
Aqu ya podemos ver que es una especie de espiral, si reducimos todava ms los intervalos
(I[i]=i/100 ; range(0,1000) podremos verla claramente:
Programas utilizados:
-Python
Libreras: numpy y matplotlib
Marcos Horno Garca
Centro: Corua