Español
Fuente/ Codesnippets

Numerische Integration uno Kurve mittels Gregory-Verfahren

 

p.specht

Integration - el zugrundeliegende Cuestión es stets: Como groß Es el Fläche bajo una cierta Funktionskurve y=f(x) zwischen el x-Grenzen a y b ? In el Praxis ha uno allerdings sólo y-Meßwerte a cierto x-Achsenwerten, sabe Así que el zugrundeliegende matemático Función no wirklich. Fast genial erscheint por lo tanto el Concepto, el Gummilineal el Mathematik, el Polynomfunktion en el Meßpunkte einzupassen y anschließend a Integrieren. Es, porque nämlich el Integral uno Polynoms formelmäßig muy bien bekannt es. Bloß el entsprechenen Koeffizienten fehlen todavía - doch como puede Kapazunder como Kepler, Euler, Gauss, Lagrange, Cotes oder eben auch el Schottisch-Britische Mathematiker, Astronom y Universitätsrektor Sir David Gregory (1659-1708), una Zeitgenosse Newtons, helfen - y zwar gründlich:

El de ihm verwendeten Formeln son vom Grad her ajustable, sodaß él el Verfahren aller vorgenannter Herren cualquier emulieren kann. Weiters son seine Koeffizientenformeln como Gewichte uno iterativen Verfahrens ligeramente implementierbar.

P.S.: Mathematische interessanter mögen Lagrange- y Tschebeyschow-Polynome ser, pero no praxisgerechter. Lediglich el Romberg-Verfahren erscheint todavía algo eleganter!
Título de la ventana " GREGORY-INTEGRATION uno eingebauten Testfunktion x^n "
Ventana de Estilo 24:Ventana 0,0-%maxx,%maxy-40:font 0:set("decimals",17)
'---------------------------------------------------------------------
' (C) ACM-TOMS ALGORITHM 280, COLLECTED ALGORITHMS FROM ACM.
' THIS WORK PUBLISHED IN COMMUNICATIONS OF THE ACM,
' VOL. 9, NO. 4, April, 1966, P.  271
'---------------------------------------------------------------------
' (D) Demo-Migration de C++ después de XProfan11.2a 2014-11
' by P.Pájaro carpintero, Wien (Austria). OHNE JEDE GEWÄHR!
'---------------------------------------------------------------------
'------------------------------------------------------------------------
' Programmanpassungen para Arraygröße y a integrierende Función
'------------------------------------------------------------------------
Var nmax&=100' Verfahren ausgelegt para esta maximalen Arraygrößen

Proc Fn_PowN :parámetros a!,n&

    ' y=x^n
    caso n&=0:volver 1

    if n&>0 : var x!=a!

        whileloop n&-1

            x!=x!*a!

        endwhile

        volver x!

    más

        Imprimir " Negativer Exponent en Fn_PowN no erlaubt!"
        beep:waitinput 20000:volver 0

    endif

ENDPROC

'------------------------------------------------------------------------
'------------------------------------------------------------------------

Proc Gregory :parámetros n&,r&,t![],w![]'findet Gewichtungskoeffizienten

    '  Computes the abscissas and weights of the Gregory quadrature rule
    '  with r differences: Given h = (t_n - t_0)/n, then holds:
    '  Integral_from t_0 to t_n of: f(t) dt =~
    '  	  h*(f_0/2 + f_1 + ... +f_n-1 + f_n/2 )
    '  	- h*12*( nabla(f_n) - delta(f_0) )
    '  	- h*24*( nabla^2(f_n) + delta^2(f_0))
    '   - ...
    '   - h*c[r+1] *( nabla^r*f(n) + delta^r*(f_0) )
    '=  Sum[j=0..n]of w[j]*f(t[j])
    'where h = (t_n - t_0)/n, and the c_j' are given en Henrici (1964, Schweiz & USA)
    'The number r must be a integer from 0 to n, the number of subdivisions.
    'The left and right endpoints must be en t(0) and t(n) respectively.
    'The abscissas are returned en t(0) to t(n) and the corresponding weights
    'en w(0) to w(n).
    '
    'If r=0 the Gregory rule is the same as the repeated trapezoid rule, and
    'if r=n the same as the Newton-Cotes rule (closed type). The order p of the
    'quadrature rule is p = r+1 for r odd and p = r+2 for r even.
    'For n >= 9 and large r some of the weights can be negative.
    '
    'For n <= 32 and r<= 24, the numerical integration of powers (less than r)
    'of x on the interval [0,1] gave 9 significant digits correct en a 11
    'digit mantissa.
    '
    '2 References:
    'Hildebrand, F. B. Introduction to Numerical Analysis.
    'McGraw-Hill, New York 1956, p. 155 ;
    'Henrici, Peter. Elements of Numerical Analysis.
    'Wiley, New York 1964, p. 252.
    'Person: https://en.wikipedia.org/wiki/Peter_Henrici_%28mathematician%28  : The Book:
    'https://ia700700.us.archive.org/23/items/ElementsOfNumericalAnalysis/Henrici-ElementsOfNumericalAnalysis.pdf
    '--------------------------------------------------------------------
    Declarar i&,j&,h!,cj!,c![nmax&+1],b![nmax&]
    b![0]=1:b![n&]=0
    c![0]=1:c![1]=-0.5
    w![0]=0.5:w![n&]=w![0]
    h!=(t![n&]-t![0])/n&

    whileloop n&-1:i&=&Loop:

        w![i&]=1
        b![i&]=0
        t![i&]=i&*h!+t![0]

    endwhile

    caso r&>n&:r&=n&

    Whileloop r&:j&=&Loop

        cj!=0.5*c![j&]

        whileloop j&,1,-1:i&=&Loop

            b![i&]=b![i&]-b![i&-1]

        endwhile

        whileloop 3,j&+2:i&=&Loop

            cj!=cj!+c![j&+2-i&]/i&

        endwhile

        c![j&+1]=-cj!

        whileloop 0,n&:i&=&Loop

            w![i&]=w![i&]-cj!*(b![n&-i&]+b![i&])

        endwhile

    Endwhile

    WhileLoop 0,n&:i&=&Loop

        w![i&]=w![i&]*h!

    endWhile

ENDPROC'Gregory

'--------------------------------------------------------------------
'  Testteil
'--------------------------------------------------------------------
declarar t![nmax&],w![nmax&]:declarar I!,In!,i&,n&,r&,p&:declarar a!,b!
a!=-1.0'Integration de a
b!= 1.0'a b
n&= 7'Grad des impliziten Polynoms
r&=n&
t![0]=a!:t![n&]=b!' Integrationsgrenzen ocupar
Gregory(n&,r&,t![],w![])' Polynom-Koeffizienten (Gregory-Gewichtungen) berechnen
' Kontrollausgabe:
font 2:Imprimir "\n       Gregory-Gewichtungen:\n "+mkstr$("-",40)

WhileLoop 0,n&:i&=&Loop

    imprimir tab(2);if(w![i&]<0,""," ");format$("%g",w![i&]),
    imprimir tab(27);if(t![i&]<0,""," ");format$("%g",t![i&])
    endwhile:imprimir
    '-----------------------------------------------------------------------
    ' Testanwendung: Integriere el Función x^p y gib el Ergebnisse de:
    '-----------------------------------------------------------------------

    whileloop 0,r&+4:p&=&Loop

        I!= ( Fn_PowN(b!,p&+1) - Fn_PowN(a!,p&+1) ) / (p&+1)
        In!=0

        whileloop 0,n&:i&=&Loop

            In!=In!+w![i&]*Fn_PowN(t![i&],p&)

        endwhile

        imprimir tab(2);n&,tab(5);r&,tab(8);p&,
        imprimir tab(13);if(I!<0,""," ");format$("%g",I!),
        imprimir tab(43);if(In!<0,""," ");format$("%g",In!),
        imprimir tab(73);if((I!-In!)<0,""," ");format$("%g",I!-In!)

    Endwhile

    BEEP
    Imprimir "\n Lo folgen el Vergleichsdaten lt. Buch [Taste]\n"+mkstr$("-",80)
    waitinput
    var wdata$=\
    "  0.086921 -1.000000 \n  0.414005 -0.714286 \n"+\
    "  0.153125 -0.428571 \n  0.345949 -0.142857 \n"+\
    "  0.345949  0.142857 \n  0.153125  0.428571 \n"+\
    "  0.414005  0.714286 \n  0.086921  1.000000 \n"
    var outdata$= "\n "+\
    "7 7  0  2.000000  2.000000  4.440892e-16 \n "+\
    "7 7  1  0.000000 -0.000000  1.110223e-16 \n "+\
    "7 7  2  0.666667  0.666667  2.220446e-16 \n "+\
    "7 7  3  0.000000 -0.000000  8.326673e-17 \n "+\
    "7 7  4  0.400000  0.400000  1.665335e-16 \n "+\
    "7 7  5  0.000000 -0.000000  8.326673e-17 \n "+\
    "7 7  6  0.285714  0.285714  0.000000e+00 \n "+\
    "7 7  7  0.000000 -0.000000  4.163336e-17 \n "+\
    "7 7  8  0.222222  0.230297 -8.075245e-03 \n "+\
    "7 7  9  0.000000 -0.000000  2.775558e-17 \n "+\
    "7 7 10  0.181818  0.202532 -2.071405e-02 \n "+\
    "7 7 11  0.000000 -0.000000  1.387779e-17"
    font 2:imprimir Wdata$,outdata$
    waitinput
    End
 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
16.05.2021  
 



Zum Quelltext


Título del Tema, max. 100 Signo.
 

Systemprofile:

Kein Systemprofil creado. [anlegen]

XProfan:

 Contribución  Font  Smilies  ▼ 

Bitte registro en una Contribución a verfassen.
 

Tema opciones

1.568 Views

Untitledvor 0 min.
Erhard Wirth14.06.2024
p.specht02.02.2022
R.Schneider20.11.2021
Uwe Lang20.11.2021
Más...

Themeninformationen

Dieses Thema ha 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Autores  |  Chat  |  Política de Privacidad  |  Descargar  |  Entrance  |  Ayuda  |  Merchantportal  |  Pie de imprenta  |  Mart  |  Interfaces  |  SDK  |  Services  |  Juegos  |  Búsqueda  |  Support

Ein Projekt aller XProfan, el lo son!


Mi XProfan
Privado Noticias
Eigenes Ablageforum
Temas-Merkliste
Eigene Beiträge
Eigene Temas
Zwischenablage
Cancelar
 Deutsch English Français Español Italia
Traducciones

Política de Privacidad


Wir uso Cookies sólo como Session-Cookies wegen el technischen Notwendigkeit y en uns hay no Cookies de Drittanbietern.

Wenn du hier en unsere Webseite klickst oder navigierst, stimmst du unserer Erfassung de Informationen en unseren Cookies en XProfan.Net a.

Weitere Informationen a unseren Cookies y dazu, como du el Kontrolle darüber behältst, findest du en unserer nachfolgenden Datenschutzerklärung.


einverstandenDatenschutzerklärung
Yo möchte no Cookie