V DC DT W QC KV C: A Mass Balance For A Pollutant in A Well-Mixed Lake Can Be Written As
V DC DT W QC KV C: A Mass Balance For A Pollutant in A Well-Mixed Lake Can Be Written As
V DC DT W QC KV C: A Mass Balance For A Pollutant in A Well-Mixed Lake Can Be Written As
TASK
dc
v =w−Qc−kv √ c
dt
25 √ c+ 10 c−100=0
Solve for the steady-state concentration, find the root using Secant method in MATLAB.
PROGRAM:
%%
%%
clc
close all
clear all
xa=0;
xb=10;
f_xa=@(x) 25*sqrt(xa)+10*xa-100;
f_xb=@(x) 25*sqrt(xb)+10*xb-100;
for i=1:8
xr=(xa*f(xb)-xb*f(xa))/(f(xb)-f(xa));
f_xr=25*sqrt(xr)+10*xr-100;
RE=abs((xr-xa)/xr)*100;
fprintf ('%6d %15.7f %15.7f %15.7f %15.7f %18.8f \n' ,
i,xa,xb,xr,f_xr,RE);
xa=xb;
f_xa=f_xb;
xb=xr;
f_xb=f_xr;
end
fprintf ('\n The root of given equation = %f \n' , xr);
OUTPUT:
f=
@(x)25*sqrt(x)+10*x-100
ans =
-100
ans =
5.9017
ans =
79.0569
i xa xb xr f(xr) RE
GRAPH:
SECANT METHOD
50 xr
0
f(c)
-50
-100
0 2 4 6 8 10
Steady-state concentration, c
More generally the function f can be defined on any matrix space with values in that
same space.
MATLAB CODE:
TASK:
dc
v =w−Qc−kv √ c
dt
25 √ c+ 10 c−100=0
Solve for the steady-state concentration, find the root using Fixed-point iteration method in
MATLAB.
PROGRAM:
%%
%%
clc
close all
clear all
for i=1:45
xr=g(xa);
g_xr=10-2.5*sqrt(xr);
RE=abs((xr-xa)/xr)*100;
fprintf('\n%3d %15.7f %15.7f %15.7f %15.7f
%18.8f\n',i,xa,xr,g_xr,RE);
xa=xr;
end
fprintf('\n The root of given equation = %f \n',xr);
OUTPUT:
f=
@(x)25*sqrt(x)+10*x-100
ans =
-100
ans =
5.9017
ans =
79.0569
i xa xr g_xr RE
1 0.0000000 10.0000000 2.0943058 100.0000000
50
xr
0
f(c)
-50
-100
0 2 4 6 8 10
Steady-state concentration, c