| TUintegTrapI | TCL UTILITIES USER MANUAL | TUintegTrapI |
|---|
| set |
TUintegTrapI  |
FunC
|
| FunC | - | Procedure which defines the function being integrated over. This is described in detail under the procedure description. |
| Beg | - | The beginning integration limit. |
| End | - | The ending integration limit. |
| ConV | - | Optional input value defaulted to 1.0e-5. This is the convergence point at which the iterations will terminate. |
| MaxI | - | Optional input value defaulted to 20. This is the maxumum number of iterations to make. If the integration converges to ConV before this value is reached the iterations will terminate early. |
| MinI | - | Optional input value defaulted to 5. This is the minimum number of iterations to make. This number of iterations are performed regardless of ConV. | DoOnce | - | Describes how FunC operates.
|
# INTEGRATE a function
# Define function Y = (x^2 + 10)^0.5
# USE this form for returning all of the function values in an interation
# step at once.
proc FunCM { X dX nP cS OuT } {
upvar $OuT Y
for { set I 0 } { $I <= $nP } { incr I } {
set Y($I) [expr sqrt($X * $X + 10.0)]
set X [expr $X + $dX]
}
}
# USE this form for returning only the value at the input X
proc FunCO { X dX nP cS } {
set Y [expr sqrt($X * $X + 10.0)]
return $Y
}
# INTEGRATE the function using DoOnce set to 1 for three different
# convergence values
set V [TUintegTrapI FunCM -2.0 5.0 1.0e-4 30 5 1]
puts stderr "Convergence 1.0e-4: Returned [format "%.5f" $V]; Actual 27.70886"
set V [TUintegTrapI FunCM -2.0 5.0 1.0e-5 30 5 1]
puts stderr "Convergence 1.0e-5: Returned [format "%.5f" $V]; Actual 27.70886"
set V [TUintegTrapI FunCM -2.0 5.0 1.0e-6 30 5 1]
puts stderr "Convergence 1.0e-6: Returned [format "%.5f" $V]; Actual 27.70886"
# INTEGRATE the function using DoOnce set to 0.
set V [TUintegTrapI FunCO -2.0 5.0 1.0e-5 30 5 0]
puts stderr ""
puts stderr "Convergence 1.0e-5: Returned [format "%.5f" $V]; Actual 27.70886"
> Convergence 1.0e-4: Returned 27.71113; Actual 27.70886
> Convergence 1.0e-5: Returned 27.70900; Actual 27.70886
> Convergence 1.0e-6: Returned 27.70887; Actual 27.70886
>
> Convergence 1.0e-5: Returned 27.70900; Actual 27.70886
| Sept 28, 2006 |
|---|