sol_hw3 - CE 335 Solutions to Homework 3 9) (a) (40 - 0)...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CE 335 Solutions to Homework 3 9) (a) (40 - 0) degC / (2*0.05) degC = 400 (need to reduce the range by this factor). log2(400) = 8.64, so 9 iterations (the maximum absolute error will decrease by a factor of 2 each iteration). (b) function T = find_T(DO) %returns the saturation temperature (degC) for a dissolved oxygen concentration (in the range 6.421 to 14.621 mg/L) ldo = log(DO); %function to find a root for f = @(Ta, ldo) -ldo - 139.34411 + 1.575701E5/Ta - 6.642308E7/(Ta^2) + 1.243800E10/ (Ta^3) - 8.621949E11/(Ta^4); %convert from centigrade to Kelvin a = 0 + 273.15; b = 40 + 273.15; fa = f(a, ldo); fb = f(b, ldo); if fa == 0 T = a - 273.15; return elseif fb == 0 T = b - 273.15; return end %ensure a bracketing interval if fa*fb > 0 error('Saturation temperature for the given dissolved oxygen concentration is not between 0 and 40 centigrade') end n_iters = 9; %from part a for i = 1:n_iters c = (a + b) / 2; fc = f(c, ldo);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
if fc == 0 T = c - 273.15; return elseif fa*fc > 0 a = c; else b = c; end end c = (a + b) / 2; T = c - 273.15; %return degrees centigrade Testing: find_T(8) >> 26.76
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/30/2011 for the course CGN 3350 taught by Professor Lybas during the Spring '11 term at University of Florida.

Page1 / 6

sol_hw3 - CE 335 Solutions to Homework 3 9) (a) (40 - 0)...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online