tc sen |
fonction [answer] = bisection si8 (al, xa, ead, G=f)
fae, la: Fanctiln emplaysthe bisection method to find the spprotiante temper sire
lik fore given saturation concentration of oxygen. The input paraacters given go this function are:
Js“ “P'Uinitial guess for lover Linte for bracket interval),
Hs zu (Anatal guest for ipper Unit for bepckst anterval),
*
”
se
|=
End (desired absolute error),
Os (given oxygen concentration).
The output 1s the temperature for thLs concentration of oxygen in freshwatey.
This function uses a helper function o(Ta, Ost) which is the equation for Te w.r.t. Osf
ing #8 Aterator
| = log2((xu ~ x1)/ead)s ‘#4 using equation 5.5 (from textbook) as the stepping criterion
| n= cellin)s #8 rounding off to the next highest Integer
printt("Using equation 5.5,\n\t the nunser of iterations required to get an absolute ercor of Af is 24", Ead, ns
printf("\niteration x1 xu x Ea\n*);## creates 2 heading
while i 2 inplies solution Lies between xr and xu
26 ad = xe #9 50, update the loner Linit
ab endif
28 | endshite
28 answer = xr;
3@. encfunction
23)
#
‘inal answer (temperature) i= xr