Listato - Funzione di Newton
Funzione Polimoniale di Newton
a passo costante
Vai ai contenuti
Menu principale:
×
Home Page
la base
la tecnica
la retta
conclusioni
Listato
Listato
download
approfondimento
Listato
Listato
Il salto programmatico.
Spiegato il "salto matematico" ora occorre spiegare il "salto programmatico".
Questa pagina è dedicata soprattutto ai programmatori.
Il sottoprogramma "Function_NG_PC" programma la base delle funzioni.
nGrado è il grado della funzione mentre tXn(W) e tYn(W) sono le Xn e le Yn.
Mentre tAn(n) sono i dati di uscita.
Il sottoprogramma "CombinazioneFunctionPassoCostante" calcola il (c,e) .
La variabile nComb = numero delle combinazioni.
La variabile nElem = numero degli elementi.
La variabile tCEPC è il valore di uscita, cioè (c,e).
Premesso che una formula matematica può essere programmata in vari modi,
nel nostro caso bisogna tenere presente il "ricorsivo".
Senza il "ricorsivo" non è possibile fare il "salto programmatico".
Per cui io devo programmare la formula come prima cosa mettendo in risalto
il "ricorsivo" e poi tutte le altre considerazioni.
Come detto in una pagina precedente il sottoprogramma "Function_NG_PC"
programma la base e rimane costante per ogni grado, mentre il sottoprogramma
"CombinazioneFunctionPassoCostante" programma (c,e) per cui la sua dimenzione
dipende da c = numero delle combinazioni .
Il listato sotto calcola al massimo nComb = 15 , per cui si può calcolare la
Funzione sino ad un massimo di nGrado = 16 .
Analizzando il listato del sottoprogramma "CombinazioneFunctionPassoCostante"
è facile capire il "ricorsivo" , e lo si può allargarlo a piacere, senza limitazione.
Per questo motivo dimenzionando opportunamente il sottoprogramma
"CombinazioneFunctionPassoCostante" è possibile arrivare al 99°.
--------------------------------------------------------------------------------------------------------------------
Private Sub Function_NG_PC()
On Error GoTo NextErr
''''''''''''''''''
th = tXn(1) - tXn(0)
''''''''''''''''''
For W = 1 To nGrado
tz = tXn(W - 1) + th
If tz <> tXn(W) Then GoTo NextErr
Next
''''''''''''''''''
For W = 0 To nGrado
tyin(W) = tYn(W)
Next
''''''''''''''''''
For W = 1 To nGrado
nGradoN = nGrado - W
tdin(nGradoN) = tyin(nGradoN + 1) - tyin(nGradoN)
Next
For K = 1 To nGrado
For W = 1 To nGrado - K
nGradoN = nGrado - W
tdin(nGradoN) = tdin(nGradoN) - tdin(nGradoN - 1)
Next
Next
''''''''''''''''''
For W = 0 To nGrado - 1
txin(W) = tXn(W)
Next
''''''''''''''''''
th = tXn(1) - tXn(0)
''''''''''''''''''
t_in(0) = 1
For W = 1 To nGrado
t_in(W) = t_in(W - 1) * W
Next
''''''''''''''''''
tain(0) = tyin(0)
For W = 1 To nGrado
tain(W) = tdin(W - 1) / (t_in(W) * th ^ W)
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If nGrado = 1 Then nComb = 1: Call CombinazioneFunctionPassoCostante: GoTo NextFine
''''''''''''''''''''''''''''''''' prima riga '''''''''''''''''''''''''''''
tAn(nGrado) = tain(nGrado)
''''''''''''''''''''''''''''''' fine prima riga ''''''''''''''''''''''''''
'''''''''''''''''''''''' prime due colonne per n-2 righe ''''''''''''''''
t_en(0) = txin(0)
For W = 1 To nGrado - 1
t_en(W) = t_en(W - 1) + txin(W)
Next
''''''''''''''''''''''''''''''
For nRig = 1 To nGrado - 1
nGradoN = nGrado - nRig
tAn(nGradoN) = tain(nGradoN) - tain(nGradoN + 1) * t_en(nGradoN)
Next
''''''''''''''''''''' fine prime due colonne per n-2 righe '''''''''''''
For nRig = 2 To nGrado - 1
nGradoN = nGrado - nRig
nComb = 2
nSegno = -1#
For nCol = nGradoN + 2 To nGrado
nElem = nCol - 1
If nSegno = 1# Then nSegno = -1# Else nSegno = 1#
Call CombinazioneFunctionPassoCostante
If EQZ_Err = -1 Then GoTo NextErr
tAn(nGradoN) = tAn(nGradoN) + nSegno * tain(nCol) * tCEPC
nComb = nComb + 1
Next
Next
''''''''''''''''''''''''''''''''' ultima riga ''''''''''''''''''''''''''''''
txen(0) = txin(0)
For W = 1 To nGrado - 1
txen(W) = txen(W - 1) * txin(W)
Next
''''''''''''''''''''''''''''''
tAn(0) = tain(0)
nSegno = 1#
For nCol = 1 To nGrado
If nSegno = 1# Then nSegno = -1# Else nSegno = 1#
tAn(0) = tAn(0) + nSegno * tain(nCol) * txen(nCol - 1)
Next
'''''''''''''''''''''''''' fine ultima riga ''''''''''''''''''''''''''''''
NextFine:
Exit Sub
NextErr:
EQZ_Err = -1
lblFunz.Caption = Space(21) + "Function - Error"
End Sub
Private Sub CombinazioneFunctionPassoCostante()
'**********************************************************************************************
'// Entrata nComb ////////////////////////////////////////////////////////////////////////
'// Entrata nElem ////////////////////////////////////////////////////////////////////////
'// Uscita tCEPC ////////////////////////////////////////////////////////////////////////
On Error GoTo NextErr
For W = 0 To 19: tJn(W) = 0: tCnEX(W) = 0: tkn(W) = 0: Next
For W = 0 To nComb: tkn(W) = nComb - W: Next
If nComb = 1 Then GoTo Next1a
If nComb = 2 Then GoTo Next2a
If nComb = 3 Then GoTo Next3a
If nComb = 4 Then GoTo Next4
If nComb = 5 Then GoTo Next5
If nComb = 6 Then GoTo Next6
If nComb = 7 Then GoTo Next7
If nComb = 8 Then GoTo Next8
If nComb = 9 Then GoTo Next9
If nComb = 10 Then GoTo Next10
If nComb = 11 Then GoTo Next11
If nComb = 12 Then GoTo Next12
If nComb = 13 Then GoTo Next13
If nComb = 14 Then GoTo Next14
If nComb = 15 Then GoTo Next15
GoTo NextErr
''''''''''''''''''''''''''''''
''''' combinazione da 1 ''''''
Next1a:
tAn(1) = tain(1)
tAn(0) = tain(0) - tain(1) * txin(0)
Exit Sub
''''' Fine combinazione da 1 ''''''
''''''''''''''''''''''''''''''
''''' combinazione da 2 ''''''
Next2a:
J1 = 0
Call Comb2ElemX
tCEPC = tC2EX
Exit Sub
''''' Fine combinazione da 2 ''''''
''''''''''''''''''''''''''''''
''''' combinazione da 3 ''''''
Next3a:
tC3EX = 0
For J1 = 1 To nElem - nComb + 2
Call Comb2ElemX
tC3EX = tC3EX + txin(J1 - 1) * tC2EX
Next
tCEPC = tC3EX
Exit Sub
''''' Fine combinazione da 3 ''''''
'''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''
''''' combinazione da n '''''''
'''''''''''''''''''''''''''''''
''''' combinazione da 15 ''''''
Next15:
tCnEX(15) = 0
tJn(13) = tJn(14) + 1
''''' combinazione da 14 ''''''
Next14:
tCnEX(14) = 0
tJn(12) = tJn(13) + 1
''''' combinazione da 13 ''''''
Next13:
tCnEX(13) = 0
tJn(11) = tJn(12) + 1
''''' combinazione da 12 ''''''
Next12:
tCnEX(12) = 0
tJn(10) = tJn(11) + 1
''''' combinazione da 11 ''''''
Next11:
tCnEX(11) = 0
tJn(9) = tJn(10) + 1
''''' combinazione da 10 ''''''
Next10:
tCnEX(10) = 0
tJn(8) = tJn(9) + 1
''''' combinazione da 9 ''''''
Next9:
tCnEX(9) = 0
tJn(7) = tJn(8) + 1
''''' combinazione da 8 ''''''
Next8:
tCnEX(8) = 0
tJn(6) = tJn(7) + 1
''''' combinazione da 7 ''''''
Next7:
tCnEX(7) = 0
tJn(5) = tJn(6) + 1
''''' combinazione da 6 ''''''
Next6:
tCnEX(6) = 0
tJn(4) = tJn(5) + 1
''''' combinazione da 5 ''''''
Next5:
tCnEX(5) = 0
tJn(3) = tJn(4) + 1
''''' combinazione da 4 ''''''
Next4:
tCnEX(4) = 0
tJn(2) = tJn(3) + 1
Next3:
tCnEX(3) = 0
For J1 = tJn(2) + 1 To nElem - nComb + tkn(1)
Call Comb2ElemX
tCnEX(3) = tCnEX(3) + txin(J1 - 1) * tC2EX
Next
tCnEX(4) = tCnEX(4) + txin(tJn(2) - 1) * tCnEX(3)
tJn(2) = tJn(2) + 1
If tJn(2) <= nElem - nComb + tkn(2) Then GoTo Next3
If nComb = 4 Then tCEPC = tCnEX(4): Exit Sub
''''' Fine combinazione da 4 ''''''
tCnEX(5) = tCnEX(5) + txin(tJn(3) - 1) * tCnEX(4)
tJn(3) = tJn(3) + 1
If tJn(3) <= nElem - nComb + tkn(3) Then GoTo Next4
If nComb = 5 Then tCEPC = tCnEX(5): Exit Sub
''''' Fine combinazione da 5 ''''''
tCnEX(6) = tCnEX(6) + txin(tJn(4) - 1) * tCnEX(5)
tJn(4) = tJn(4) + 1
If tJn(4) <= nElem - nComb + tkn(4) Then GoTo Next5
If nComb = 6 Then tCEPC = tCnEX(6): Exit Sub
''''' Fine combinazione da 6 ''''''
tCnEX(7) = tCnEX(7) + txin(tJn(5) - 1) * tCnEX(6)
tJn(5) = tJn(5) + 1
If tJn(5) <= nElem - nComb + tkn(5) Then GoTo Next6
If nComb = 7 Then tCEPC = tCnEX(7): Exit Sub
''''' Fine combinazione da 7 ''''''
tCnEX(8) = tCnEX(8) + txin(tJn(6) - 1) * tCnEX(7)
tJn(6) = tJn(6) + 1
If tJn(6) <= nElem - nComb + tkn(6) Then GoTo Next7
If nComb = 8 Then tCEPC = tCnEX(8): Exit Sub
''''' Fine combinazione da 8 ''''''
tCnEX(9) = tCnEX(9) + txin(tJn(7) - 1) * tCnEX(8)
tJn(7) = tJn(7) + 1
If tJn(7) <= nElem - nComb + tkn(7) Then GoTo Next8
If nComb = 9 Then tCEPC = tCnEX(9): Exit Sub
''''' Fine combinazione da 9 ''''''
tCnEX(10) = tCnEX(10) + txin(tJn(8) - 1) * tCnEX(9)
tJn(8) = tJn(8) + 1
If tJn(8) <= nElem - nComb + tkn(8) Then GoTo Next9
If nComb = 10 Then tCEPC = tCnEX(10): Exit Sub
''''' Fine combinazione da 10 ''''''
tCnEX(11) = tCnEX(11) + txin(tJn(9) - 1) * tCnEX(10)
tJn(9) = tJn(9) + 1
If tJn(9) <= nElem - nComb + tkn(9) Then GoTo Next10
If nComb = 11 Then tCEPC = tCnEX(11): Exit Sub
''''' Fine combinazione da 11 ''''''
tCnEX(12) = tCnEX(12) + txin(tJn(10) - 1) * tCnEX(11)
tJn(10) = tJn(10) + 1
If tJn(10) <= nElem - nComb + tkn(10) Then GoTo Next11
If nComb = 12 Then tCEPC = tCnEX(12): Exit Sub
''''' Fine combinazione da 12 ''''''
tCnEX(13) = tCnEX(13) + txin(tJn(11) - 1) * tCnEX(12)
tJn(11) = tJn(11) + 1
If tJn(11) <= nElem - nComb + tkn(11) Then GoTo Next12
If nComb = 13 Then tCEPC = tCnEX(13): Exit Sub
''''' Fine combinazione da 13 ''''''
tCnEX(14) = tCnEX(14) + txin(tJn(12) - 1) * tCnEX(13)
tJn(12) = tJn(12) + 1
If tJn(12) <= nElem - nComb + tkn(12) Then GoTo Next13
If nComb = 14 Then tCEPC = tCnEX(14): Exit Sub
''''' Fine combinazione da 14 ''''''
tCnEX(15) = tCnEX(15) + txin(tJn(13) - 1) * tCnEX(14)
tJn(13) = tJn(13) + 1
If tJn(13) <= nElem - nComb + tkn(13) Then GoTo Next14
If nComb = 15 Then tCEPC = tCnEX(15): Exit Sub
''''' Fine combinazione da 15 ''''''
Exit Sub
NextErr:
EQZ_Err = -1
End Sub
Private Sub Comb2ElemX()
On Error GoTo NextErr
tC2EX = 0
For J = J1 + 1 To nElem
tC1EX = 0
For W = J To nElem
tC1EX = tC1EX + txin(W)
Next
tC2EX = tC2EX + txin(J - 1) * tC1EX
Next
Exit Sub
NextErr:
EQZ_Err = -1
End Sub
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Home Page
download
Home Page
|
la base
|
la tecnica
|
la retta
|
conclusioni
|
Listato
|
Mappa generale del sito
di Ambrosini Cesare
Torna ai contenuti
|
Torna al menu
Per poter utilizzare questo sito è necessario attivare JavaScript.