| |
|
|
p.specht
| Die Interpolation mittels Tschebyschow-Polynomen zeichnet sich durch einen sehr günstigen, gleichmäßigen Fehlerverlauf aus. Dazu sind als Interpolationsstellen die geeignet verschobenen Nullstellen eines Tschebyschow-Polynoms passenden Grades zu verwenden. Das erste der beiden nachstehenden Programme erlaubt die Berechnung der Polynom-Koeffizienten geeignet zu wählenden Grades.
"Fein-Tuning": Falls man den Werte-Gültigkeitsbereich einschränken kann, genügen Tschebyschow-Polynome geringeren Grades, die auch schneller zu berechnen sind. Das zweite der nachstehenden Programme erlaubt so eine Grad-Reduktion.
WindowStyle 24:Font 2:Set("decimals",5)
WindowTitle "ChebySer: Tschebyschowpolynomkoeffizienten für unterschiedliche Grade (Formeloptimierung)"
' Quelle: https://jean-pierre.moreau.pagesperso-orange.fr/Basic/chebyser_bas.txt
' Transponiert nach XProfan 11.2a (D) Demo by P.Specht, Vienna/Austria
' No warranty whatsoever! Keine wie auch immer geartete Gewähr!
'****************************************************
'* Program to demonstrate Chebyser subroutine *
'* ------------------------------------------------ *
'* Reference: BASIC Scientific Subroutines, Vol. II *
'* by F.R. Ruckdeschel, BYTE/McGRAWW-HILL, 1981 [1].*
'* ------------------------------------------------ *
'* SAMPLE RUN: *
'* *
'* Chebyshev polynomial coefficients for degree 2 *
'* A( 0) = -1 *
'* A( 1) = 0 *
'* A( 2) = 2 *
'* *
'* Chebyshev polynomial coefficients for degree 3 *
'* A( 0) = 0 *
'* A( 1) = -3 *
'* A( 2) = 0 *
'* A( 3) = 4 *
'* *
'* Chebyshev polynomial coefficients for degree 4 *
'* A( 0) = 1 *
'* A( 1) = 0 *
'* A( 2) = -8 *
'* A( 3) = 0 *
'* A( 4) = 8 *
'* *
'* Chebyshev polynomial coefficients for degree 5 *
'* A( 0) = 0 *
'* A( 1) = 5 *
'* A( 2) = 0 *
'* A( 3) = -20 *
'* A( 4) = 0 *
'* A( 5) = 16 *
'* *
'* Chebyshev polynomial coefficients for degree 6 *
'* A( 0) = -1 *
'* A( 1) = 0 *
'* A( 2) = 18 *
'* A( 3) = 0 *
'* A( 4) = -48 *
'* A( 5) = 0 *
'* A( 6) = 32 *
'* *
'* Chebyshev polynomial coefficients for degree 7 *
'* A( 0) = 0 *
'* A( 1) = -7 *
'* A( 2) = 0 *
'* A( 3) = 56 *
'* A( 4) = 0 *
'* A( 5) = -112 *
'* A( 6) = 0 *
'* A( 7) = 64 *
'* *
'* Chebyshev polynomial coefficients for degree 8 *
'* A( 0) = 1 *
'* A( 1) = 0 *
'* A( 2) = -32 *
'* A( 3) = 0 *
'* A( 4) = 160 *
'* A( 5) = 0 *
'* A( 6) = -256 *
'* A( 7) = 0 *
'* A( 8) = 128 *
'* *
'* Chebyshev polynomial coefficients for degree 9 *
'* A( 0) = 0 *
'* A( 1) = 9 *
'* A( 2) = 0 *
'* A( 3) = -120 *
'* A( 4) = 0 *
'* A( 5) = 432 *
'* A( 6) = 0 *
'* A( 7) = -576 *
'* A( 8) = 0 *
'* A( 9) = 256 *
'* *
'* Chebyshev polynomial coefficients for degree 10 *
'* A( 0) = -1 *
'* A( 1) = 0 *
'* A( 2) = 50 *
'* A( 3) = 0 *
'* A( 4) = -400 *
'* A( 5) = 0 *
'* A( 6) = 1120 *
'* A( 7) = 0 *
'* A( 8) = -1280 *
'* A( 9) = 0 *
'* A( 10) = 512 *
'* *
'****************************************************
'DEFINT I-N
'DEFDBL A-H, O-Z
Declare i&,n&,j&
CLS
PRINT
Declare B![10,10]
WhileLoop 2,10:n&=&Loop
S1000' Proc-Aufruf
PRINT " Tschebyschowpolynom-Koeffizienten für Polynomgrad ";n&
Print
WhileLoop 0,n&:i&=&Loop
PRINT " A(";i&; ") = ";B![n&,i&]
EndWhile
Print : Case n&<10:WaitInput
EndWhile
PRINT
END
Proc S1000
'********************************************************
'* Chebyshev series coefficients evaluation subroutine *
'* ---------------------------------------------------- *
'* The order of the polynomial is n. The coefficients *
'* are returned in the array B(i,j), i is the degree of *
'* the polynomial, j is the coefficient order. *
'********************************************************
'Establish t0 and t1 coefficients
B![0,0]=1:B![1,0]=0:B![1,1]=1
'Return if order is less than two
Case n&<2:Return
WhileLoop 2,n&:i&=&Loop
WhileLoop i&:j&=&Loop
'Basic recursion relation
B![i&,j&]=2*B![i&-1,j&-1]-B![i&-2,j&]
EndWhile
B![i&,0]= -1*B![i&-2, 0]
EndWhile
EndProc
'End of file Chebyser.prf
Zweites Programm:
WindowStyle 24:Font 2:Set("decimals",17)
WindowTitle "ChebeCon: Vereinfachung von Approximationspolynomen nach Tschebyschow"
' Quelle: https://jean-pierre.moreau.pagesperso-orange.fr/Basic/chebecon_bas.txt
' transponiert nach XProfan 11.2a (D) Demo 2016-12 by P.Specht, Vienna/Austria
' No warranty whatsoever! Ohne jegliche Gewähr!
'*****************************************************
'* Program to demonstrate Chebyshev economization *
'* ------------------------------------------------- *
'* Reference: BASIC Scientific Subroutines, Vol. II *
'* by F.R. Ruckdeschel, BYTE/McGRAWW-HILL, 1981 [1]. *
'* ------------------------------------------------- *
'* SAMPLE RUN: *
'* What is the degree of the input polynomial: ? 15 *
'* *
'* What is the degree of the desired economized *
'* polynomial: ? 9 *
'* *
'* What is the range of the input polynomial: ? 1.57 *
'* *
'* Input the coefficients: *
'* C( 0) = ? 0 *
'* C( 1) = ? 1 *
'* C( 2) = ? 0 *
'* C( 3) = ? -.166666666 *
'* C( 4) = ? 0 *
'* C( 5) = ? .00833333333 *
'* C( 6) = ? 0 *
'* C( 7) = ? -.0001984127 *
'* C( 8) = ? 0 *
'* C( 9) = ? .000002755732 *
'* C( 10) = ? 0 *
'* C( 11) = ? -.000000025052109 *
'* C( 12) = ? 0 *
'* C( 13) = ? .00000000016059045 *
'* C( 14) = ? 0 *
'* C( 15) = ? -.00000000000076471635 *
'* *
'* The Chebyshev series coefficients are: *
'* *
'* A( 0) = 0.0000000000 *
'* A( 1) = 1.1334708982 *
'* A( 2) = 0.0000000000 *
'* A( 3) = -0.1378841454 *
'* A( 4) = 0.0000000000 *
'* A( 5) = 0.0044798168 *
'* A( 6) = 0.0000000000 *
'* A( 7) = -0.0000674667 *
'* A( 8) = 0.0000000000 *
'* A( 9) = 0.0000005865 *
'* A(10) = 0.0000000000 *
'* A(11) = -0.0000000033 *
'* A(12) = 0.0000000000 *
'* A(13) = 0.0000000000 *
'* A(14) = 0.0000000000 *
'* A(15) = 0.0000000000 *
'* *
'* The economized polynomial coefficients are: *
'* *
'* C( 0) = 0.0000000000 *
'* C( 1) = 0.9999999767 *
'* C( 2) = 0.0000000000 *
'* C( 3) = -1.6666647620 *
'* C( 4) = 0.0000000000 *
'* C( 5) = 0.0083329009 *
'* C( 6) = 0.0000000000 *
'* C( 7) = -0.0001980098 *
'* C( 8) = 0.0000000000 *
'* C( 9) = 0.0000025907 *
'* *
'*****************************************************
'DEFINT I-N
'DEFDBL A-H, O-Z
DecLARE m&,m1&,x0!,i&,j&,cc$
Declare b!,n&,L&
CLS
Print
Print " Bitte den Grad des Original-Polynoms eingeben: ", :Input m&
PRINT
Print " Bitte den gewünschten Grad des vereinfachten Polynoms angeben: ",:Input m1&
PRINT
Print " Bitte den gewünschten Bereich (Range) angeben: ",:Input x0!
Declare A![m&],B![m&,m&],C![m&]
Print
Print " Eingabe der Koeffizienten des Originalpolynoms:"
Print
WhileLoop 0,m&:i&=&Loop
Print " C(";i&; ") = ";:Input Cc$
C![i&]=Val(cc$)
EndWhile
Print
S2000' Proc-Aufruf
PRINT " Die Koeffizienten der Tschebyschow-Folge lauten: \n"
WhileLoop 0,m&:i&=&Loop
PRINT " A(";i&;") = ";+Format$( "#0.##########",A![i&])
EndWhile
Print:WaitInput 6000
Print "\n Die Koeffizienten des vereinfachten Polynoms lauten: \n"
WhileLoop 0,m1&:i&=&Loop
PRINT " C(";i&,") = ";Format$("#0.##########",C![i&])
EndWhile
Beep:WaitInput
END
Proc S1000
'********************************************************
'* Chebyshev series coefficients evaluation subroutine *
'* The order of the polynomial is n. The coefficients *
'* are returned in the array B(i,j), i is the degree of *
'* the polynomial, j is the coefficient order. *
'********************************************************
'Establish t0 and t1 coefficients
B![0,0] = 1: B![1,0] = 0: B![1,1] = 1
'Return if order is less than two:
Case n& < 2 : Return
WhileLoop 2,n&:i&=&Loop
WhileLoop i&:j&=&Loop
'Basic recursion relation
B![i&,j&] = 2*B![i&-1,j&-1]-B![i&-2,j&]
EndWhile
B![i&,0]= -1*B![i&-2,0]
EndWhile
EndProc
Proc S2000
'************************************************************
'* Chebyshev economization subroutine. The program takes *
'* the input polynomial coefficients, C(i), and returns the *
'* Chebyshev series coefficients, A(i). The degree of the *
'* series passed to the routine is m. The degree of the *
'* series returned is m1. The maximum range of x is x0 used *
'* for scaling. Note that the input series coefficients are *
'* nulled during the process, and then set equal to the *
'* economized series coefficients. *
'************************************************************
'Start by scaling the input coefficients according to C(i)
B!=x0!
WhileLoop m&:i&=&Loop
C![i&]=C![i&]*B!
B!=B!*x0!
EndWhile
'Call Chebyshev series coefficients subroutine
WhileLoop m&,0,-1:n&=&Loop
S1000'proc-Aufruf
A![n&]=C![n&]/B![n&,n&]
WhileLoop 0,n&:l&=&Loop
'Chebyshev series of order l is substracted out of the polynomial
C![L&]=C![l&]-A![n&]*B![n&,l&]
EndWhile
EndWhile
'Perform truncation
WhileLoop 0,m1&:i&=&Loop
WhileLoop 0,i&:j&=&Loop
C![j&] = C![j&] + A![i&] * B![i&,j&]
EndWhile
EndWhile
'Convert back to the interval X0
B!=1/x0!
WhileLoop m1&:i&=&Loop
C![i&]=C![i&]*B!
B!=B!/x0!
EndWhile
EndProc
'End of file Chebecon.prf
|
|
|
| Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 22.05.2021 ▲ |
|
|
|