EBK NUMERICAL METHODS FOR ENGINEERS
EBK NUMERICAL METHODS FOR ENGINEERS
7th Edition
ISBN: 8220100254147
Author: Chapra
Publisher: MCG
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 21P

Recall from Sec. 8.2 that determining the chemistry of water exposed to atmospheric CO 2 can be determined by solving five nonlinear equations ( Eqs .8 .6 through 8 .10 ) for five unknowns: c T , [ HCO 3 ] , [ CO 3 2 ] , [ H + ] ,  and  [ OH ] . Employing the parameters from Sec. 8.2 and the program developed in Prob. 9.20, solve this system for conditions in 1958 when the partial pressure of CO 2 was 315 ppm. Use your results to compute the pH.

Expert Solution & Answer
Check Mark
To determine

To calculate: The solutions of the system offive nonlinear equations (refer section 8.2) given by,

K1=106[H+][HCO3]KHpCO2K2=[H+][CO32][HCO3]cT=KHpCO2106+[HCO3]+[CO32]Kw=[H+][OH]0=[HCO3]+2[CO32]+[OH][H+]

And, to compute the pH of the rainwater.

Answer to Problem 21P

Solution: The solution to the system of five nonlinear equations is [H+]=2.3419×106, [OH]=4.2701×109, cT=1.3260×105, [HCO3]=2.3375×106, and [CO32]=5.0025×1011.

The pH of the rainwater is 5.6304.

Explanation of Solution

Given Information:

The system offivesimultaneousnonlinear equations,

K1=106[H+][HCO3]KHpCO2K2=[H+][CO32][HCO3]

cT=KHpCO2106+[HCO3]+[CO32]Kw=[H+][OH]0=[HCO3]+2[CO32]+[OH][H+]

Here, KH is Henry’s constant, cT is total inorganic carbon, [HCO3] is bicarbonate, Kw,K1, and K2 are equilibrium constants, [H+] is hydrogen ion, [CO32] is carbonate, and [OH] is hydroxyl ion.

The values of constants KH,K1,K2, and Kw are as follows:

KH=101,46K1=106.3K2=1010.3Kw=1014

Consider, the value of partial pressure of CO2 in 1958 as,

pCO2=315 ppm

Formula used:

For system of n simultaneous nonlinear equations formulated as,

f1(x1,x2,...,xn)=0f2(x1,x2,...,xn)=0...fn1(x1,x2,...,xn)=0fn(x1,x2,...,xn)=0

From Newton-Raphson method, for mth equation,

fm,i+1=fm,i+(x1,i+1x1,i)fm,ix1+(x2,i+1x2,i)fm,ix2+...+(xn,i+1xn,i)fm,ixn

Here, m represents the equation and the second subscript represents the value of the function at current value i or at next value i+1.

Further, the above equation is rewritten as,

fm,i+x1,ifm,ix1+x2,ifm,ix2+...+xn,ifm,ixn=x1,i+1fm,ix1+x2,i+1fm,ix2+...+xn,i+1fm,ixn

Write the matrix equation for partial derivatives.

[Z]=[f1,ix1f1,ix2...f1,ixnf2,ix1f2,ix2...f2,ixn.........fn,ix1fn,ix2...fn,ixn]

Initial and the final values are expressed as,

{Xi}T=[x1,ix2,i...xn,i]

And,

{Xi+1}T=[x1,i+1x2,i+1...xn,i+1]

Write the function values at i as,

{Fi}T=|f1,if2,i...fn,i|

Thus, simplify the partial derivative equation as,

[Z]{Xi+1}={Fi}+[Z]{Xi}

The above equation can then be solved iteratively to obtain the solutions to the system of nonlinear equations.

Calculation:

Apply a technique based on Newton-Raphson method to solve the system of nonlinear equations.

Use the following MATLAB code toimplement Newton Raphson method and solve the given system of simultaneous nonlinear equations.

function Code_9_21P()

format short g

x0=[10^-7;10^-7;1e-5;2e-6;5e-11];

KH=10^-1.46;K1=10^-6.3;K2=10^-10.3;Kw=10^-14;pco2=315;

[x,f,e_a,itr]=newtmult(@jfrain,x0,[],[],KH,K1,K2,Kw,pco2);

fprintf('H: %2.4e\n',x(1))

fprintf('OH: %2.4e\n',x(2))

fprintf('cT: %2.4e\n',x(3))

fprintf('HCO3: %2.4e\n',x(4))

fprintf('CO3: %2.4e\n\n',x(5))

fprintf('Maximum relative error = %2.4g percent\n',e_a)

fprintf('Number of iterations = %d',itr)

pH=-log10(x(1));

fprintf('\npH: %2.4f\n',pH)

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function[x,f,e_a,itr]=newtmult(func,x0,es,maxit,varargin)

% check for minimum input required

ifnargin<2,error('Provide at least 2 arguments for input'), end

ifnargin<3||isempty(es),es=0.0001;end

ifnargin<4||isempty(maxit),maxit=50;end

% initialize

itr=0; x=x0;

while(1)

[J,f]=func(x,varargin{:});

dx=J\f;

x=x-dx;

% increase counter in every run of the loop

itr=itr+1;

e_a=100*max(abs(dx./x));

% stopping criteria

ifitr>=maxit||e_a<=es, break, end

end

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function[J,f]=jfrain(x,varargin)

del=0.00001;

% determine the elements of J matrix

df1dx1=(f1(x(1)+del*x(1),x(2),x(3),x(4),x(5),varargin{:})-...

f1(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(1));

%

df1dx2=(f1(x(1),x(2)+del*x(2),x(3),x(4),x(5),varargin{:})-...

f1(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(2));

%

df1dx3=(f1(x(1),x(2),x(3)+del*x(3),x(4),x(5),varargin{:})-...

f1(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(3));

%

df1dx4=(f1(x(1),x(2),x(3),x(4)+del*x(4),x(5),varargin{:})-...

f1(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(4));

%

df1dx5=(f1(x(1),x(2),x(3),x(4),x(5)+del*x(5),varargin{:})-...

f1(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(5));

%

df2dx1=(f2(x(1)+del*x(1),x(2),x(3),x(4),x(5),varargin{:})-...

f2(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(1));

%

df2dx2=(f2(x(1),x(2)+del*x(2),x(3),x(4),x(5),varargin{:})-...

f2(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(2));

%

df2dx3=(f2(x(1),x(2),x(3)+del*x(3),x(4),x(5),varargin{:})-...

f2(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(3));

%

df2dx4=(f2(x(1),x(2),x(3),x(4)+del*x(4),x(5),varargin{:})-...

f2(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(4));

%

df2dx5=(f2(x(1),x(2),x(3),x(4),x(5)+del*x(5),varargin{:})-...

f2(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(5));

%

df3dx1=(f3(x(1)+del*x(1),x(2),x(3),x(4),x(5),varargin{:})-...

f3(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(1));

%

df3dx2=(f3(x(1),x(2)+del*x(2),x(3),x(4),x(5),varargin{:})-...

f3(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(2));

%

df3dx3=(f3(x(1),x(2),x(3)+del*x(3),x(4),x(5),varargin{:})-...

f3(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(3));

%

df3dx4=(f3(x(1),x(2),x(3),x(4)+del*x(4),x(5),varargin{:})-...

f3(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(4));

%

df3dx5=(f3(x(1),x(2),x(3),x(4),x(5)+del*x(5),varargin{:})-...

f3(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(5));

%

df4dx1=(f4(x(1)+del*x(1),x(2),x(3),x(4),x(5),varargin{:})-...

f4(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(1));

%

df4dx2=(f4(x(1),x(2)+del*x(2),x(3),x(4),x(5),varargin{:})-...

f4(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(2));

%

df4dx3=(f4(x(1),x(2),x(3)+del*x(3),x(4),x(5),varargin{:})-...

f4(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(3));

%

df4dx4=(f4(x(1),x(2),x(3),x(4)+del*x(4),x(5),varargin{:})-...

f4(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(4));

%

df4dx5=(f4(x(1),x(2),x(3),x(4),x(5)+del*x(5),varargin{:})-...

f4(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(5));

%

df5dx1=(f5(x(1)+del*x(1),x(2),x(3),x(4),x(5),varargin{:})-...

f5(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(1));

%

df5dx2=(f5(x(1),x(2)+del*x(2),x(3),x(4),x(5),varargin{:})-...

f5(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(2));

%

df5dx3=(f5(x(1),x(2),x(3)+del*x(3),x(4),x(5),varargin{:})-...

f5(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(3));

%

df5dx4=(f5(x(1),x(2),x(3),x(4)+del*x(4),x(5),varargin{:})-...

f5(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(4));

%

df5dx5=(f5(x(1),x(2),x(3),x(4),x(5)+del*x(5),varargin{:})-...

f5(x(1),x(2),x(3),x(4),x(5),varargin{:}))/(del*x(5));

% define the J matrix

J=[df1dx1 df1dx2 df1dx3 df1dx4 df1dx5

df2dx1 df2dx2 df2dx3 df2dx4 df2dx5

df3dx1 df3dx2 df3dx3 df3dx4 df3dx5

df4dx1 df4dx2 df4dx3 df4dx4 df4dx5

df5dx1 df5dx2 df5dx3 df5dx4 df5dx5];

% determine the elements of f vector.

f11=f1(x(1),x(2),x(3),x(4),x(5),varargin{:});

f22=f2(x(1),x(2),x(3),x(4),x(5),varargin{:});

f33=f3(x(1),x(2),x(3),x(4),x(5),varargin{:});

f44=f4(x(1),x(2),x(3),x(4),x(5),varargin{:});

f55=f5(x(1),x(2),x(3),x(4),x(5),varargin{:});

% define the elements of f vector.

f=[f11;f22;f33;f44;f55];

end

% define the five non-linear equations

% first equation

function f=f1(H,OH,cT,HCO3,CO3,KH,K1,K2,Kw,pco2)

f =1e6*H*HCO3/KH/pco2-K1;

end

% second equation

function f=f2(H,OH,cT,HCO3,CO3,KH,K1,K2,Kw,pco2)

f = H*CO3/HCO3-K2;

end

% third equation

function f=f3(H,OH,cT,HCO3,CO3,KH,K1,K2,Kw,pco2)

f = H*OH-Kw;

end

% fourth equation

function f=f4(H,OH,cT,HCO3,CO3,KH,K1,K2,Kw,pco2)

f = KH*pco2/1e6+HCO3+CO3-cT;

end

% fifth equation

function f=f5(H,OH,cT,HCO3,CO3,KH,K1,K2,Kw,pco2)

f = HCO3+2*CO3+OH-H;

end

Execute the above code to obtain the solutions as,

H: 2.3419e-06

OH: 4.2701e-09

cT: 1.3260e-05

HCO3: 2.3375e-06

CO3: 5.0025e-11

Maximum relative error = 1.265e-12 percent

Number of iterations = 6

pH: 5.6304

Hence, the solution to the system of five nonlinear equations is [H+]=2.3419×106, [OH]=4.2701×109, cT=1.3260×105, [HCO3]=2.3375×106, [CO32]=5.0025×1011, and the pH of the rainwater is 5.6304.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
15B.4 Please help me answer this math problem.
ACT.1 EQUATION SLOPE POINT 1 POINT 2 INTERCEPT YA b.2xya12 C Sx Sy-15 0 d. y x +5
Sp

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
1. How much money is Joe earning when he’s 30?

Pathways To Math Literacy (looseleaf)

Provide an example of a qualitative variable and an example of a quantitative variable.

Elementary Statistics ( 3rd International Edition ) Isbn:9781260092561

Find E(X) for each of the distributions given in Exercise 2.1-3.

Probability And Statistical Inference (10th Edition)

Evaluate the integrals in Exercises 1–46. 1.

University Calculus: Early Transcendentals (4th Edition)

Use the ideas in drawings a and b to find the solution to Gausss Problem for the sum 1+2+3+...+n. Explain your ...

A Problem Solving Approach To Mathematics For Elementary School Teachers (13th Edition)

Knowledge Booster
Background pattern image
Mechanical Engineering
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, mechanical-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Mathematics For Machine Technology
Advanced Math
ISBN:9781337798310
Author:Peterson, John.
Publisher:Cengage Learning,
Text book image
Linear Algebra: A Modern Introduction
Algebra
ISBN:9781285463247
Author:David Poole
Publisher:Cengage Learning
Text book image
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:9781133382119
Author:Swokowski
Publisher:Cengage
Text book image
Trigonometry (MindTap Course List)
Trigonometry
ISBN:9781337278461
Author:Ron Larson
Publisher:Cengage Learning
Mod-01 Lec-01 Discrete probability distributions (Part 1); Author: nptelhrd;https://www.youtube.com/watch?v=6x1pL9Yov1k;License: Standard YouTube License, CC-BY
Discrete Probability Distributions; Author: Learn Something;https://www.youtube.com/watch?v=m9U4UelWLFs;License: Standard YouTube License, CC-BY
Probability Distribution Functions (PMF, PDF, CDF); Author: zedstatistics;https://www.youtube.com/watch?v=YXLVjCKVP7U;License: Standard YouTube License, CC-BY
Discrete Distributions: Binomial, Poisson and Hypergeometric | Statistics for Data Science; Author: Dr. Bharatendra Rai;https://www.youtube.com/watch?v=lHhyy4JMigg;License: Standard Youtube License