SlideShare a Scribd company logo
1 of 56
Download to read offline
Lecture 4—Intro Solving Non-Linear Equations (NLEs)
Outline
1 Introduction
The solution of a non-linear equation is a Root Finding Problem
2 Built-In Solution in Matlab: fzero
3 Built-In Solution in Excel: Solver
Enabling the solver
Using the solver
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 1 / 16
Features of a non-linear function
− 4 −2 0 2 4
−50
0
50 Roots
x
y
f(x) = −2x3
− x2
+ 20x + 1 Finding the roots of equations is one
of the most common numerical
tasks
Equations of state
Empirical relationships for friction
factors, heat transfer coefficients
Solution to complicated mass &
energy balances
>> p = [-2 -1 20 1 ]% Tell MATLAB about the polynomial
>> r = roots (p)
r =
-3.398872 2.948760 -0.049888
5 >> fplot ( @(x) polyval (p,x), [-4.5 4] , ’r’ );
>> plot ( [0 0 0], r, ’bo’,’markerface’,’blue’);
Command line:
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 2 / 16
Features of a non-linear function
−4 −2 0 2 4
−50
0
50
∂f
∂x
= 0 ∂2
f
∂x2 > 0
∂f
∂x
= 0 ∂2
f
∂x2 < 0
Extrema
x
y
f(x) = −2x3
− x2
+ 20x + 1 Optimization methods allow the
maxima or minima of a function to
be located
Applications:
Minimize the cost of a process by
adjusting its parameters
Maximize the yield or selectivity of
a reaction by adjusting tempera-
ture/pressure/concentration
>> p = [-2 -1 20 1 ]% Tell MATLAB about the polynomial
>> r = roots (p)
r =
-3.398872 2.948760 -0.049888
5 >> fplot ( @(x) polyval (p,x), [-4.5 4] , ’r’ );
>> plot ( [0 0 0], r, ’bo’,’markerface’,’blue’);
Command line:
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 2 / 16
Matlab built-in support for polynomials
Matlab has a number of functions to help with polynomials. These functions all use a
coefficient array to describe the polynomial:
Math
P1(x) = −2x3
− x2
+ 20x + 1
P2(x) = x4
− x2
+ 2x
Matlab Coefficient Array
>> p1 = [ -2, -1, 20, 1 ];
>> p2 = [ 1, 0, -1, 2, 0 ];
Command line:
The order n of a polynomial is its largest exponent.
The coefficient array has a total of n + 1 elements.
The first element of the coefficient array is the coefficient of the highest power
(called the order) of the polynomial.
The last element is the value of the constant.
Matlab functions that deal with polynomials:
y = polyval(p, x) Evaluate polynomial p at x
r = roots(p) Return array of all n roots (real + complex) of p.
p = polyfit(x,y,n) Fit data y vs. x to a polynomial of order n. x and y
must have the same length, which must be at least
n + 1. For example n = 1 is just a line, and you need
at least 2 points to define a line.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 3 / 16
Solving for the root — Where to start?
Transforming the equation
Consider the Redlich-Kwong Equation of State
P =
RT
V − b
−
a
V(V + b)
√
T
42 44 46 48 50
0
2
4
6
·105
V, cm3
mol
P,bar
T = 60o C
methyl chloride
This function has no real roots
P ≤ 0 is not a physical pressure
We are usually interested in the
V (at a given T) that gives us a
certain P
How is this a root-finding
problem?
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 4 / 16
Solving for the root — Where to start?
Transforming the equation
Consider the Redlich-Kwong Equation of State
1 =
RT
V − b
−
a
V(V + b)
√
T
42 44 46 48 50
0
2
4
6
·105
V, cm3
mol
P,bar
T = 60o C
methyl chloride
Suppose we want to know the
V corresponding to P = 1 bar
We can substitute this choice
into the equation.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 4 / 16
Solving for the root — Where to start?
Transforming the equation
Consider the Redlich-Kwong Equation of State
1 −
RT
V − b
−
a
V(V + b)
√
T
= 0
0.2 0.4 0.6 0.8 1
·105
0
0.5
V, cm3
mol
1−P,bar
T = 60o C
methyl chloride
Now rearrange the equation so
that the RHS is zero.
The resulting equality is only
true when the right V is
selected
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 4 / 16
Solving for the root — Where to start?
Transforming the equation
Consider the Redlich-Kwong Equation of State
1 −
RT
V − b
−
a
V(V + b)
√
T
= f(V)
0.2 0.4 0.6 0.8 1
·105
0
0.5
V, cm3
mol
1−P,bar
T = 60o C
methyl chloride
Now rearrange the equation so
that the RHS is zero.
The resulting equality is only
true when the right V is
selected
As V is varied the right-hand
side varies.
f(V) is a transformed form of
the RK EOS
f(V) = 0 is the solution to our
problem
We can see from the plot that
the correct molar volume is
near 30,000 cm3
mol
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 4 / 16
Solving for the root — Where to start?
Transforming the equation into its root-finding form
First Step — Form the ‘‘Root-finding function’’
Any equality with 1 unknown can be transformed into a function whose
roots satisfy the equality
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
Solving for the root — Where to start?
Transforming the equation into its root-finding form
First Step — Form the ‘‘Root-finding function’’
Any equality with 1 unknown can be transformed into a function whose
roots satisfy the equality
In general, root-finding methods apply when we have an equality
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
Solving for the root — Where to start?
Transforming the equation into its root-finding form
First Step — Form the ‘‘Root-finding function’’
Any equality with 1 unknown can be transformed into a function whose
roots satisfy the equality
In general, root-finding methods apply when we have an equality
1 with 1 unknown x
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
Solving for the root — Where to start?
Transforming the equation into its root-finding form
First Step — Form the ‘‘Root-finding function’’
Any equality with 1 unknown can be transformed into a function whose
roots satisfy the equality
In general, root-finding methods apply when we have an equality
1 with 1 unknown x
2 and any number of specified parameters {pi}:
left(x, {pi}) = right(x, {pi}) (1)
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
Solving for the root — Where to start?
Transforming the equation into its root-finding form
First Step — Form the ‘‘Root-finding function’’
Any equality with 1 unknown can be transformed into a function whose
roots satisfy the equality
In general, root-finding methods apply when we have an equality
1 with 1 unknown x
2 and any number of specified parameters {pi}:
left(x, {pi}) = right(x, {pi}) (1)
We can form a function f(x, {pi}):
f(x, {pi}) = left(x, {pi}) − right(x, {pi})
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
Solving for the root — Where to start?
Transforming the equation into its root-finding form
First Step — Form the ‘‘Root-finding function’’
Any equality with 1 unknown can be transformed into a function whose
roots satisfy the equality
In general, root-finding methods apply when we have an equality
1 with 1 unknown x
2 and any number of specified parameters {pi}:
left(x, {pi}) = right(x, {pi}) (1)
We can form a function f(x, {pi}):
f(x, {pi}) = left(x, {pi}) − right(x, {pi})
The roots of f correspond to solutions of (1). f(V) is the root-finding function.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
Solving for the root — Where to start?
Transforming the equation
Example
P =
RT
V − b
−
a
V(V + b)
√
T
Find V such that P = 1 atm and T = 60o
C
What are {pi } (the fixed parameters)?
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
Solving for the root — Where to start?
Transforming the equation
Example
P =
RT
V − b
−
a
V(V + b)
√
T
Find V such that P = 1 atm and T = 60o
C
What are {pi } (the fixed parameters)?
p1 = R 83.14
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
Solving for the root — Where to start?
Transforming the equation
Example
P =
RT
V − b
−
a
V(V + b)
√
T
Find V such that P = 1 atm and T = 60o
C
What are {pi } (the fixed parameters)?
p1 = R 83.14
p2 = a
0.4274 R2 T2.5
c
Pc
= 1.5641 × 108
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
Solving for the root — Where to start?
Transforming the equation
Example
P =
RT
V − b
−
a
V(V + b)
√
T
Find V such that P = 1 atm and T = 60o
C
What are {pi } (the fixed parameters)?
p1 = R 83.14
p2 = a
0.4274 R2 T2.5
c
Pc
= 1.5641 × 108
p3 = b 0.08664 R Tc
Pc
= 44.8909
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
Solving for the root — Where to start?
Transforming the equation
Example
P =
RT
V − b
−
a
V(V + b)
√
T
Find V such that P = 1 atm and T = 60o
C
What are {pi } (the fixed parameters)?
p1 = R 83.14
p2 = a
0.4274 R2 T2.5
c
Pc
= 1.5641 × 108
p3 = b 0.08664 R Tc
Pc
= 44.8909
p4 = T 60 o
C
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
Solving for the root — Where to start?
Transforming the equation
Example
P =
RT
V − b
−
a
V(V + b)
√
T
Find V such that P = 1 atm and T = 60o
C
What are {pi } (the fixed parameters)?
p1 = R 83.14
p2 = a
0.4274 R2 T2.5
c
Pc
= 1.5641 × 108
p3 = b 0.08664 R Tc
Pc
= 44.8909
p4 = T 60 o
C
p5 = P 1 bar
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
Solving for the root — Where to start?
Transforming the equation
Example
P =
RT
V − b
−
a
V(V + b)
√
T
Find V such that P = 1 atm and T = 60o
C
What are {pi } (the fixed parameters)?
p1 = R 83.14
p2 = a
0.4274 R2 T2.5
c
Pc
= 1.5641 × 108
p3 = b 0.08664 R Tc
Pc
= 44.8909
p4 = T 60 o
C
p5 = P 1 bar
x = V
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
Solving for the root — Where to start?
Transforming the equation
Example
P =
RT
V − b
−
a
V(V + b)
√
T
Find V such that P = 1 atm and T = 60o
C
What are {pi } (the fixed parameters)?
p1 = R 83.14
p2 = a
0.4274 R2 T2.5
c
Pc
= 1.5641 × 108
p3 = b 0.08664 R Tc
Pc
= 44.8909
p4 = T 60 o
C
p5 = P 1 bar
x = V
f(V, {R; a; b; T; P}) = 1 −
RT
V − b
−
a
V(V + b)
√
T
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
fzero — The Matlab tool for solving Non-Linear equations
A typical problem
Find the molar volume of methyl chloride vapor such that at T = 60 ◦C the pressure is 1 bar.
Use the Redlich-Kwong Equation of State:
P =
RT
V − b
−
a
V(V + b)
√
T
Variable Value Unit
a 0.42748R2
Tc
2.5
Pc
cm6
·bar·K0.5
mol2
b 0.08664RTc
Pc
cm3
mol
R 83.14 cm3
·bar
mol·K
Tc 416.15 K
Pc 66.8 bar
Quick Solution with Matlab
Define the parameters. Note how the pressure is defined as a function_handle.
>> Pc = 66.8; Tc = 416.15; R = 83.14;
>> a = 0.42748 .* R^2 .* Tc .^ 2.5 ./ Pc;
>> b = 0.08664 .* R .* Tc ./ Pc;
>> T = 60 + 273.15;
5 >> P = @(V) R .* T ./ (V-b) - a ./ (V .* (V+b) .* sqrt(T));
>> root_finding_equation = @(V) 1 - P(V);
>> V = fzero( root_finding_equation, 30000 )
V = 27431.8744533891
Script-file: find_methyl_chloride_P.m
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 7 / 16
fzero — The Matlab tool for solving Non-Linear equations
A typical problem
Find the molar volume of methyl chloride vapor such that at T = 60 ◦C the pressure is 1 bar.
Use the Redlich-Kwong Equation of State:
P =
RT
V − b
−
a
V(V + b)
√
T
Variable Value Unit
a 0.42748R2
Tc
2.5
Pc
cm6
·bar·K0.5
mol2
b 0.08664RTc
Pc
cm3
mol
R 83.14 cm3
·bar
mol·K
Tc 416.15 K
Pc 66.8 bar
Quick Solution with Matlab
This is the important part! This function_handle will have a value of zero when the
correct molar volume is found.
>> Pc = 66.8; Tc = 416.15; R = 83.14;
>> a = 0.42748 .* R^2 .* Tc .^ 2.5 ./ Pc;
>> b = 0.08664 .* R .* Tc ./ Pc;
>> T = 60 + 273.15;
5 >> P = @(V) R .* T ./ (V-b) - a ./ (V .* (V+b) .* sqrt(T));
>> root_finding_equation = @(V) 1 - P(V);
>> V = fzero( root_finding_equation, 30000 )
V = 27431.8744533891
Script-file: find_methyl_chloride_P.m
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 7 / 16
fzero — The Matlab tool for solving Non-Linear equations
Quick Solution with Matlab
Now we solve for V numerically. fzero takes two arguments.
(1) The first is a function_handle that accepts exactly 1 argument.
(2) The second argument is an initial guess.
Why did I use 30000 for the initial guess? A few slides ago I plotted this function and
noted visually that the correct molar volume was around 30,000 cm3
mol
.
I just used fzero in OPEN mode. I’m telling Matlab to look near 30,000 cm3
mol
but I
place no restrictions on what range of molar volumes to try.
>> Pc = 66.8; Tc = 416.15; R = 83.14;
>> a = 0.42748 .* R^2 .* Tc .^ 2.5 ./ Pc;
>> b = 0.08664 .* R .* Tc ./ Pc;
>> T = 60 + 273.15;
5 >> P = @(V) R .* T ./ (V-b) - a ./ (V .* (V+b) .* sqrt(T));
>> root_finding_equation = @(V) 1 - P(V);
>> V = fzero( root_finding_equation, 30000 )
V = 27431.8744533891
Script-file: find_methyl_chloride_P.m
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 7 / 16
fzero — The Matlab tool for solving Non-Linear equations
Quick Solution with Matlab
Why did I use 30000 for the initial guess? A few slides ago I plotted this function and
noted visually that the correct molar volume was around 30,000 cm3
mol
.
I just used fzero in OPEN mode. I’m telling Matlab to look near 30,000 cm3
mol
but I
place no restrictions on what range of molar volumes to try.
We can also use fzero in CLOSED mode.
The initial guess I provided is a 2-element array.
It tells Matlab:
‘‘The root_finding_equation has a value of zero
somewhere between 20000 and 40000’’
>> Pc = 66.8; Tc = 416.15; R = 83.14;
>> a = 0.42748 .* R^2 .* Tc .^ 2.5 ./ Pc;
>> b = 0.08664 .* R .* Tc ./ Pc;
>> T = 60 + 273.15;
5 >> P = @(V) R .* T ./ (V-b) - a ./ (V .* (V+b) .* sqrt(T));
>> root_finding_equation = @(V) 1 - P(V);
>> V = fzero( root_finding_equation, [20000 40000] )
V = 27431.8744533891
Script-file: find_methyl_chloride_P.m
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 7 / 16
fzero — The Matlab tool for solving Non-Linear equations
Quick Solution with Matlab
We can also use fzero in CLOSED mode.
The initial guess I provided is a 2-element array.
It tells Matlab:
‘‘The root_finding_equation has a value of zero
somewhere between 20000 and 40000’’
If I’m wrong and root_finding_equation does not in fact have a zero in this
interval I’ll get an error
>> Pc = 66.8; Tc = 416.15; R = 83.14;
>> a = 0.42748 .* R^2 .* Tc .^ 2.5 ./ Pc;
>> b = 0.08664 .* R .* Tc ./ Pc;
>> T = 60 + 273.15;
5 >> P = @(V) R .* T ./ (V-b) - a ./ (V .* (V+b) .* sqrt(T));
>> root_finding_equation = @(V) 1 - P(V);
>> V = fzero( root_finding_equation, [20000 25000] )
??? Error using fzero (line 274)
??? The function values at the interval endpoints must differ in sign.
Script-file: find_methyl_chloride_P.m
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 7 / 16
Outline
1 Introduction
The solution of a non-linear equation is a Root Finding Problem
2 Built-In Solution in Matlab: fzero
3 Built-In Solution in Excel: Solver
Enabling the solver
Using the solver
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 8 / 16
Solving non-linear equations in Excel
Excel has a tool called Solver that can perform two different tasks
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 9 / 16
Solving non-linear equations in Excel
Excel has a tool called Solver that can perform two different tasks
1 Set the value of a cell to a particular value by changing other cells.
This is what we’re interested in right now.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 9 / 16
Solving non-linear equations in Excel
Excel has a tool called Solver that can perform two different tasks
1 Set the value of a cell to a particular value by changing other cells.
This is what we’re interested in right now.
2 Minimize/maximize the value of a cell by changing other cells.
We will come back to this one later.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 9 / 16
Solving non-linear equations in Excel
Excel has a tool called Solver that can perform two different tasks
1 Set the value of a cell to a particular value by changing other cells.
This is what we’re interested in right now.
2 Minimize/maximize the value of a cell by changing other cells.
We will come back to this one later.
The Solver Add-In is not enabled by default, although on College
of Engineering machines this has usually been done by the system
administrator.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 9 / 16
Solving non-linear equations in Excel
Excel has a tool called Solver that can perform two different tasks
1 Set the value of a cell to a particular value by changing other cells.
This is what we’re interested in right now.
2 Minimize/maximize the value of a cell by changing other cells.
We will come back to this one later.
The Solver Add-In is not enabled by default, although on College
of Engineering machines this has usually been done by the system
administrator.
If you don’t see the following under the Data tab in Excel, then the
next few slides show you how to get it.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 9 / 16
Enable the Solver Add-In
Go to the File tab and select Options
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 10 / 16
Enable the Solver Add-In
In the dialog that appears, select Add-Ins
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 10 / 16
Enable the Solver Add-In
In the next dialog, ensure that the Manage: box is showing Excel
Add-ins and select Go...
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 10 / 16
Enable the Solver Add-In
In the next dialog, ensure that Solver Add-in is checked and then
click OK
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 10 / 16
Outline
1 Introduction
The solution of a non-linear equation is a Root Finding Problem
2 Built-In Solution in Matlab: fzero
3 Built-In Solution in Excel: Solver
Enabling the solver
Using the solver
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 11 / 16
Using Solver to Solve Non-linear equations
A typical problem
Find the molar volume of methyl chloride vapor such that at T = 60 ◦C the pressure is 1 bar.
Use the Redlich-Kwong Equation of State:
P =
RT
V − b
−
a
V(V + b)
√
T
Variable Value Unit
a 0.42748R2
Tc
2.5
Pc
cm6
·bar·K0.5
mol2
b 0.08664RTc
Pc
cm3
mol
R 83.14 cm3
·bar
mol·K
Tc 416.15 K
Pc 66.8 bar
Here’s a good start to solving the problem. The way I’ve set this spreadsheet up so far
has a few features I’d like to point out.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 12 / 16
Good practice with spreadsheets
Formatting is important! Ask anyone who’s had to share a spreadsheet with their boss.
Make what you’re doing clear!
Use variable names
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 13 / 16
Good practice with spreadsheets
Formatting is important! Ask anyone who’s had to share a spreadsheet with their boss.
Make what you’re doing clear!
Use variable names
Use superscripts and subscripts and the Symbol font to make variable names
appear as close to their mathematical representation as possible.
The keyboard shortcut CTRL + 1 is worth leaning to make this chore easier.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 13 / 16
Good practice with spreadsheets
Formatting is important! Ask anyone who’s had to share a spreadsheet with their boss.
Make what you’re doing clear!
Use variable names
Use superscripts and subscripts and the Symbol font to make variable names
appear as close to their mathematical representation as possible.
The keyboard shortcut CTRL + 1 is worth leaning to make this chore easier.
Keep parameters (constants) separate from values that you will be changing
frequently.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 13 / 16
Good practice with spreadsheets
Formatting is important! Ask anyone who’s had to share a spreadsheet with their boss.
Make what you’re doing clear!
Use variable names
Use superscripts and subscripts and the Symbol font to make variable names
appear as close to their mathematical representation as possible.
The keyboard shortcut CTRL + 1 is worth leaning to make this chore easier.
Keep parameters (constants) separate from values that you will be changing
frequently.
Keep calculated values distinguished from user-manipulated values. In this
example values I entered manually Are in an easily recognized font.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 13 / 16
Good practice with spreadsheets
Formatting is important! Ask anyone who’s had to share a spreadsheet with their boss.
Make what you’re doing clear!
Use variable names
Use superscripts and subscripts and the Symbol font to make variable names
appear as close to their mathematical representation as possible.
The keyboard shortcut CTRL + 1 is worth leaning to make this chore easier.
Keep parameters (constants) separate from values that you will be changing
frequently.
Keep calculated values distinguished from user-manipulated values. In this
example values I entered manually Are in an easily recognized font.
Include units!! Again, take the time to use superscripts.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 13 / 16
Good practice with spreadsheets
Use Names to Make Formulas Readable
Make what you’re doing clear!
The box to the left of the formula bar is for giving cells human-friendly names.
Use it!
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 14 / 16
Good practice with spreadsheets
Use Names to Make Formulas Readable
Make what you’re doing clear!
The box to the left of the formula bar is for giving cells human-friendly names.
Use it!
Some names (like R) can’t be used. I usually append an underscore _ when
this is the case.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 14 / 16
Good practice with spreadsheets
Use Names to Make Formulas Readable
Make what you’re doing clear!
The box to the left of the formula bar is for giving cells human-friendly names.
Use it!
Some names (like R) can’t be used. I usually append an underscore _ when
this is the case.
For variables with numerical subscripts, e.g., T1, enter the name as T_1.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 14 / 16
Good practice with spreadsheets
Use Names to Make Formulas Readable
Make what you’re doing clear!
The box to the left of the formula bar is for giving cells human-friendly names.
Use it!
Some names (like R) can’t be used. I usually append an underscore _ when
this is the case.
For variables with numerical subscripts, e.g., T1, enter the name as T_1.
Look at how nice my formula for a is to read, it gives you a warm and fuzzy
feeling doesn’t it?
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 14 / 16
Good practice with spreadsheets
Use Names to Make Formulas Readable
Make what you’re doing clear!
The box to the left of the formula bar is for giving cells human-friendly names.
Use it!
Some names (like R) can’t be used. I usually append an underscore _ when
this is the case.
For variables with numerical subscripts, e.g., T1, enter the name as T_1.
Similarly, I can also tell by looking at the cell formula that this is the RK
Equation of State.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 14 / 16
Setting up the problem for Solver
Now I’m going to define my root-finding cell.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 15 / 16
Setting up the problem for Solver
Now I’m going to define my root-finding cell.
And now open up the Solver (it’s in the Data tab).
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 15 / 16
The Solver dialog.
The Solver dialog has a lot going on inside of it. For now, we only
need to use the top three rows.
Set Objective This is the address of the cell you want to solve for.
We want the Difference: cell to assume a value of 0.
Click that cell and its address will appear in the Set
Objective box.
To: Here is where we decide between root-finding (Value
of:) and min/max problems.
We want the difference between the actual pressure
and 1 bar to be 0, so Value of: should be selected
with a value of 0 in the box.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 16 / 16
The Solver dialog.
Now tell Solver which cells to manipulate in order to make the
difference 0. Click on the Range Selector Tool
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 16 / 16
The Solver dialog.
We want to change the molar volume. Click it
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 16 / 16
The Solver dialog.
We’re ready! Click Solve
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 16 / 16
The Solver dialog.
All done. Notice the volume has changed to 27431.9, and the
Difference: is 8.48e-07. Pretty close to zero. If that’s not close
enough, we can tweak the tolerance in the Solver.
Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 16 / 16

More Related Content

What's hot

Some properties of m sequences over finite field fp
Some properties of m sequences over finite field fpSome properties of m sequences over finite field fp
Some properties of m sequences over finite field fpIAEME Publication
 
lecture 1
lecture 1lecture 1
lecture 1sajinsc
 
Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Deepak John
 
1 chapter1 introduction
1 chapter1 introduction1 chapter1 introduction
1 chapter1 introductionSSE_AndyLi
 
Variational Bayes: A Gentle Introduction
Variational Bayes: A Gentle IntroductionVariational Bayes: A Gentle Introduction
Variational Bayes: A Gentle IntroductionFlavio Morelli
 
Reading Seminar (140515) Spectral Learning of L-PCFGs
Reading Seminar (140515) Spectral Learning of L-PCFGsReading Seminar (140515) Spectral Learning of L-PCFGs
Reading Seminar (140515) Spectral Learning of L-PCFGsKeisuke OTAKI
 
Otter 2016-11-28-01-ss
Otter 2016-11-28-01-ssOtter 2016-11-28-01-ss
Otter 2016-11-28-01-ssRuo Ando
 
2. polynomial interpolation
2. polynomial interpolation2. polynomial interpolation
2. polynomial interpolationEasyStudy3
 
Expressiveness and Model of the Polymorphic λ Calculus
Expressiveness and Model of the Polymorphic λ CalculusExpressiveness and Model of the Polymorphic λ Calculus
Expressiveness and Model of the Polymorphic λ Calculusevastsdsh
 
Elliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve CryptographyElliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve CryptographyMd. Al-Amin Khandaker Nipu
 
lecture 4
lecture 4lecture 4
lecture 4sajinsc
 

What's hot (20)

Some properties of m sequences over finite field fp
Some properties of m sequences over finite field fpSome properties of m sequences over finite field fp
Some properties of m sequences over finite field fp
 
Function and graphs
Function and graphsFunction and graphs
Function and graphs
 
lecture 1
lecture 1lecture 1
lecture 1
 
Computer Science Assignment Help
Computer Science Assignment Help Computer Science Assignment Help
Computer Science Assignment Help
 
Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Analysis and design of algorithms part 4
Analysis and design of algorithms part 4
 
Function
Function Function
Function
 
1 chapter1 introduction
1 chapter1 introduction1 chapter1 introduction
1 chapter1 introduction
 
Variational Bayes: A Gentle Introduction
Variational Bayes: A Gentle IntroductionVariational Bayes: A Gentle Introduction
Variational Bayes: A Gentle Introduction
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Reading Seminar (140515) Spectral Learning of L-PCFGs
Reading Seminar (140515) Spectral Learning of L-PCFGsReading Seminar (140515) Spectral Learning of L-PCFGs
Reading Seminar (140515) Spectral Learning of L-PCFGs
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Otter 2016-11-28-01-ss
Otter 2016-11-28-01-ssOtter 2016-11-28-01-ss
Otter 2016-11-28-01-ss
 
2. polynomial interpolation
2. polynomial interpolation2. polynomial interpolation
2. polynomial interpolation
 
Numerical Methods 1
Numerical Methods 1Numerical Methods 1
Numerical Methods 1
 
Expressiveness and Model of the Polymorphic λ Calculus
Expressiveness and Model of the Polymorphic λ CalculusExpressiveness and Model of the Polymorphic λ Calculus
Expressiveness and Model of the Polymorphic λ Calculus
 
Elliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve CryptographyElliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve Cryptography
 
Lec4
Lec4Lec4
Lec4
 
lecture 4
lecture 4lecture 4
lecture 4
 
Chemistry Assignment Help
Chemistry Assignment Help Chemistry Assignment Help
Chemistry Assignment Help
 
Analysis of Algorithm
Analysis of AlgorithmAnalysis of Algorithm
Analysis of Algorithm
 

Similar to Lecture 4 f17

5.5 Zeros of Polynomial Functions
5.5 Zeros of Polynomial Functions5.5 Zeros of Polynomial Functions
5.5 Zeros of Polynomial Functionssmiller5
 
Master method
Master method Master method
Master method Rajendran
 
Diaconis Ylvisaker 1985
Diaconis Ylvisaker 1985Diaconis Ylvisaker 1985
Diaconis Ylvisaker 1985Julyan Arbel
 
S1 - Process product optimization using design experiments and response surfa...
S1 - Process product optimization using design experiments and response surfa...S1 - Process product optimization using design experiments and response surfa...
S1 - Process product optimization using design experiments and response surfa...CAChemE
 
Bisection & Regual falsi methods
Bisection & Regual falsi methodsBisection & Regual falsi methods
Bisection & Regual falsi methodsDivya Bhatia
 
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program CorrectnessCMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctnessallyn joy calcaben
 
Dataflow Analysis
Dataflow AnalysisDataflow Analysis
Dataflow AnalysisMiller Lee
 
Bounded solutions of certain (differential and first order
Bounded solutions of certain (differential and first orderBounded solutions of certain (differential and first order
Bounded solutions of certain (differential and first orderAlexander Decker
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquerVikas Sharma
 
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...mathsjournal
 
lecture 11
lecture 11lecture 11
lecture 11sajinsc
 
DeepLearn2022 1. Goals & AlgorithmDesign.pdf
DeepLearn2022 1. Goals & AlgorithmDesign.pdfDeepLearn2022 1. Goals & AlgorithmDesign.pdf
DeepLearn2022 1. Goals & AlgorithmDesign.pdfSean Meyn
 
Propositional logic in Discretes tructures.pptx
Propositional logic in Discretes tructures.pptxPropositional logic in Discretes tructures.pptx
Propositional logic in Discretes tructures.pptxShaukatAliChaudhry1
 

Similar to Lecture 4 f17 (20)

5.5 Zeros of Polynomial Functions
5.5 Zeros of Polynomial Functions5.5 Zeros of Polynomial Functions
5.5 Zeros of Polynomial Functions
 
Matlab lecture 6 – newton raphson method@taj copy
Matlab lecture 6 – newton raphson method@taj   copyMatlab lecture 6 – newton raphson method@taj   copy
Matlab lecture 6 – newton raphson method@taj copy
 
Master method
Master method Master method
Master method
 
calculus-4c-1.pdf
calculus-4c-1.pdfcalculus-4c-1.pdf
calculus-4c-1.pdf
 
Ch2 (1).ppt
Ch2 (1).pptCh2 (1).ppt
Ch2 (1).ppt
 
Diaconis Ylvisaker 1985
Diaconis Ylvisaker 1985Diaconis Ylvisaker 1985
Diaconis Ylvisaker 1985
 
Raices primitivas
Raices primitivasRaices primitivas
Raices primitivas
 
S1 - Process product optimization using design experiments and response surfa...
S1 - Process product optimization using design experiments and response surfa...S1 - Process product optimization using design experiments and response surfa...
S1 - Process product optimization using design experiments and response surfa...
 
Bisection & Regual falsi methods
Bisection & Regual falsi methodsBisection & Regual falsi methods
Bisection & Regual falsi methods
 
L16
L16L16
L16
 
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program CorrectnessCMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
 
Dataflow Analysis
Dataflow AnalysisDataflow Analysis
Dataflow Analysis
 
Bounded solutions of certain (differential and first order
Bounded solutions of certain (differential and first orderBounded solutions of certain (differential and first order
Bounded solutions of certain (differential and first order
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...
Fractional Newton-Raphson Method and Some Variants for the Solution of Nonlin...
 
lecture 11
lecture 11lecture 11
lecture 11
 
Ijetr011954
Ijetr011954Ijetr011954
Ijetr011954
 
DeepLearn2022 1. Goals & AlgorithmDesign.pdf
DeepLearn2022 1. Goals & AlgorithmDesign.pdfDeepLearn2022 1. Goals & AlgorithmDesign.pdf
DeepLearn2022 1. Goals & AlgorithmDesign.pdf
 
Dynamic programing
Dynamic programingDynamic programing
Dynamic programing
 
Propositional logic in Discretes tructures.pptx
Propositional logic in Discretes tructures.pptxPropositional logic in Discretes tructures.pptx
Propositional logic in Discretes tructures.pptx
 

Recently uploaded

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 

Recently uploaded (20)

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 

Lecture 4 f17

  • 1. Lecture 4—Intro Solving Non-Linear Equations (NLEs) Outline 1 Introduction The solution of a non-linear equation is a Root Finding Problem 2 Built-In Solution in Matlab: fzero 3 Built-In Solution in Excel: Solver Enabling the solver Using the solver Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 1 / 16
  • 2. Features of a non-linear function − 4 −2 0 2 4 −50 0 50 Roots x y f(x) = −2x3 − x2 + 20x + 1 Finding the roots of equations is one of the most common numerical tasks Equations of state Empirical relationships for friction factors, heat transfer coefficients Solution to complicated mass & energy balances >> p = [-2 -1 20 1 ]% Tell MATLAB about the polynomial >> r = roots (p) r = -3.398872 2.948760 -0.049888 5 >> fplot ( @(x) polyval (p,x), [-4.5 4] , ’r’ ); >> plot ( [0 0 0], r, ’bo’,’markerface’,’blue’); Command line: Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 2 / 16
  • 3. Features of a non-linear function −4 −2 0 2 4 −50 0 50 ∂f ∂x = 0 ∂2 f ∂x2 > 0 ∂f ∂x = 0 ∂2 f ∂x2 < 0 Extrema x y f(x) = −2x3 − x2 + 20x + 1 Optimization methods allow the maxima or minima of a function to be located Applications: Minimize the cost of a process by adjusting its parameters Maximize the yield or selectivity of a reaction by adjusting tempera- ture/pressure/concentration >> p = [-2 -1 20 1 ]% Tell MATLAB about the polynomial >> r = roots (p) r = -3.398872 2.948760 -0.049888 5 >> fplot ( @(x) polyval (p,x), [-4.5 4] , ’r’ ); >> plot ( [0 0 0], r, ’bo’,’markerface’,’blue’); Command line: Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 2 / 16
  • 4. Matlab built-in support for polynomials Matlab has a number of functions to help with polynomials. These functions all use a coefficient array to describe the polynomial: Math P1(x) = −2x3 − x2 + 20x + 1 P2(x) = x4 − x2 + 2x Matlab Coefficient Array >> p1 = [ -2, -1, 20, 1 ]; >> p2 = [ 1, 0, -1, 2, 0 ]; Command line: The order n of a polynomial is its largest exponent. The coefficient array has a total of n + 1 elements. The first element of the coefficient array is the coefficient of the highest power (called the order) of the polynomial. The last element is the value of the constant. Matlab functions that deal with polynomials: y = polyval(p, x) Evaluate polynomial p at x r = roots(p) Return array of all n roots (real + complex) of p. p = polyfit(x,y,n) Fit data y vs. x to a polynomial of order n. x and y must have the same length, which must be at least n + 1. For example n = 1 is just a line, and you need at least 2 points to define a line. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 3 / 16
  • 5. Solving for the root — Where to start? Transforming the equation Consider the Redlich-Kwong Equation of State P = RT V − b − a V(V + b) √ T 42 44 46 48 50 0 2 4 6 ·105 V, cm3 mol P,bar T = 60o C methyl chloride This function has no real roots P ≤ 0 is not a physical pressure We are usually interested in the V (at a given T) that gives us a certain P How is this a root-finding problem? Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 4 / 16
  • 6. Solving for the root — Where to start? Transforming the equation Consider the Redlich-Kwong Equation of State 1 = RT V − b − a V(V + b) √ T 42 44 46 48 50 0 2 4 6 ·105 V, cm3 mol P,bar T = 60o C methyl chloride Suppose we want to know the V corresponding to P = 1 bar We can substitute this choice into the equation. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 4 / 16
  • 7. Solving for the root — Where to start? Transforming the equation Consider the Redlich-Kwong Equation of State 1 − RT V − b − a V(V + b) √ T = 0 0.2 0.4 0.6 0.8 1 ·105 0 0.5 V, cm3 mol 1−P,bar T = 60o C methyl chloride Now rearrange the equation so that the RHS is zero. The resulting equality is only true when the right V is selected Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 4 / 16
  • 8. Solving for the root — Where to start? Transforming the equation Consider the Redlich-Kwong Equation of State 1 − RT V − b − a V(V + b) √ T = f(V) 0.2 0.4 0.6 0.8 1 ·105 0 0.5 V, cm3 mol 1−P,bar T = 60o C methyl chloride Now rearrange the equation so that the RHS is zero. The resulting equality is only true when the right V is selected As V is varied the right-hand side varies. f(V) is a transformed form of the RK EOS f(V) = 0 is the solution to our problem We can see from the plot that the correct molar volume is near 30,000 cm3 mol Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 4 / 16
  • 9. Solving for the root — Where to start? Transforming the equation into its root-finding form First Step — Form the ‘‘Root-finding function’’ Any equality with 1 unknown can be transformed into a function whose roots satisfy the equality Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
  • 10. Solving for the root — Where to start? Transforming the equation into its root-finding form First Step — Form the ‘‘Root-finding function’’ Any equality with 1 unknown can be transformed into a function whose roots satisfy the equality In general, root-finding methods apply when we have an equality Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
  • 11. Solving for the root — Where to start? Transforming the equation into its root-finding form First Step — Form the ‘‘Root-finding function’’ Any equality with 1 unknown can be transformed into a function whose roots satisfy the equality In general, root-finding methods apply when we have an equality 1 with 1 unknown x Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
  • 12. Solving for the root — Where to start? Transforming the equation into its root-finding form First Step — Form the ‘‘Root-finding function’’ Any equality with 1 unknown can be transformed into a function whose roots satisfy the equality In general, root-finding methods apply when we have an equality 1 with 1 unknown x 2 and any number of specified parameters {pi}: left(x, {pi}) = right(x, {pi}) (1) Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
  • 13. Solving for the root — Where to start? Transforming the equation into its root-finding form First Step — Form the ‘‘Root-finding function’’ Any equality with 1 unknown can be transformed into a function whose roots satisfy the equality In general, root-finding methods apply when we have an equality 1 with 1 unknown x 2 and any number of specified parameters {pi}: left(x, {pi}) = right(x, {pi}) (1) We can form a function f(x, {pi}): f(x, {pi}) = left(x, {pi}) − right(x, {pi}) Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
  • 14. Solving for the root — Where to start? Transforming the equation into its root-finding form First Step — Form the ‘‘Root-finding function’’ Any equality with 1 unknown can be transformed into a function whose roots satisfy the equality In general, root-finding methods apply when we have an equality 1 with 1 unknown x 2 and any number of specified parameters {pi}: left(x, {pi}) = right(x, {pi}) (1) We can form a function f(x, {pi}): f(x, {pi}) = left(x, {pi}) − right(x, {pi}) The roots of f correspond to solutions of (1). f(V) is the root-finding function. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 5 / 16
  • 15. Solving for the root — Where to start? Transforming the equation Example P = RT V − b − a V(V + b) √ T Find V such that P = 1 atm and T = 60o C What are {pi } (the fixed parameters)? Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
  • 16. Solving for the root — Where to start? Transforming the equation Example P = RT V − b − a V(V + b) √ T Find V such that P = 1 atm and T = 60o C What are {pi } (the fixed parameters)? p1 = R 83.14 Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
  • 17. Solving for the root — Where to start? Transforming the equation Example P = RT V − b − a V(V + b) √ T Find V such that P = 1 atm and T = 60o C What are {pi } (the fixed parameters)? p1 = R 83.14 p2 = a 0.4274 R2 T2.5 c Pc = 1.5641 × 108 Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
  • 18. Solving for the root — Where to start? Transforming the equation Example P = RT V − b − a V(V + b) √ T Find V such that P = 1 atm and T = 60o C What are {pi } (the fixed parameters)? p1 = R 83.14 p2 = a 0.4274 R2 T2.5 c Pc = 1.5641 × 108 p3 = b 0.08664 R Tc Pc = 44.8909 Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
  • 19. Solving for the root — Where to start? Transforming the equation Example P = RT V − b − a V(V + b) √ T Find V such that P = 1 atm and T = 60o C What are {pi } (the fixed parameters)? p1 = R 83.14 p2 = a 0.4274 R2 T2.5 c Pc = 1.5641 × 108 p3 = b 0.08664 R Tc Pc = 44.8909 p4 = T 60 o C Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
  • 20. Solving for the root — Where to start? Transforming the equation Example P = RT V − b − a V(V + b) √ T Find V such that P = 1 atm and T = 60o C What are {pi } (the fixed parameters)? p1 = R 83.14 p2 = a 0.4274 R2 T2.5 c Pc = 1.5641 × 108 p3 = b 0.08664 R Tc Pc = 44.8909 p4 = T 60 o C p5 = P 1 bar Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
  • 21. Solving for the root — Where to start? Transforming the equation Example P = RT V − b − a V(V + b) √ T Find V such that P = 1 atm and T = 60o C What are {pi } (the fixed parameters)? p1 = R 83.14 p2 = a 0.4274 R2 T2.5 c Pc = 1.5641 × 108 p3 = b 0.08664 R Tc Pc = 44.8909 p4 = T 60 o C p5 = P 1 bar x = V Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
  • 22. Solving for the root — Where to start? Transforming the equation Example P = RT V − b − a V(V + b) √ T Find V such that P = 1 atm and T = 60o C What are {pi } (the fixed parameters)? p1 = R 83.14 p2 = a 0.4274 R2 T2.5 c Pc = 1.5641 × 108 p3 = b 0.08664 R Tc Pc = 44.8909 p4 = T 60 o C p5 = P 1 bar x = V f(V, {R; a; b; T; P}) = 1 − RT V − b − a V(V + b) √ T Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 6 / 16
  • 23. fzero — The Matlab tool for solving Non-Linear equations A typical problem Find the molar volume of methyl chloride vapor such that at T = 60 ◦C the pressure is 1 bar. Use the Redlich-Kwong Equation of State: P = RT V − b − a V(V + b) √ T Variable Value Unit a 0.42748R2 Tc 2.5 Pc cm6 ·bar·K0.5 mol2 b 0.08664RTc Pc cm3 mol R 83.14 cm3 ·bar mol·K Tc 416.15 K Pc 66.8 bar Quick Solution with Matlab Define the parameters. Note how the pressure is defined as a function_handle. >> Pc = 66.8; Tc = 416.15; R = 83.14; >> a = 0.42748 .* R^2 .* Tc .^ 2.5 ./ Pc; >> b = 0.08664 .* R .* Tc ./ Pc; >> T = 60 + 273.15; 5 >> P = @(V) R .* T ./ (V-b) - a ./ (V .* (V+b) .* sqrt(T)); >> root_finding_equation = @(V) 1 - P(V); >> V = fzero( root_finding_equation, 30000 ) V = 27431.8744533891 Script-file: find_methyl_chloride_P.m Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 7 / 16
  • 24. fzero — The Matlab tool for solving Non-Linear equations A typical problem Find the molar volume of methyl chloride vapor such that at T = 60 ◦C the pressure is 1 bar. Use the Redlich-Kwong Equation of State: P = RT V − b − a V(V + b) √ T Variable Value Unit a 0.42748R2 Tc 2.5 Pc cm6 ·bar·K0.5 mol2 b 0.08664RTc Pc cm3 mol R 83.14 cm3 ·bar mol·K Tc 416.15 K Pc 66.8 bar Quick Solution with Matlab This is the important part! This function_handle will have a value of zero when the correct molar volume is found. >> Pc = 66.8; Tc = 416.15; R = 83.14; >> a = 0.42748 .* R^2 .* Tc .^ 2.5 ./ Pc; >> b = 0.08664 .* R .* Tc ./ Pc; >> T = 60 + 273.15; 5 >> P = @(V) R .* T ./ (V-b) - a ./ (V .* (V+b) .* sqrt(T)); >> root_finding_equation = @(V) 1 - P(V); >> V = fzero( root_finding_equation, 30000 ) V = 27431.8744533891 Script-file: find_methyl_chloride_P.m Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 7 / 16
  • 25. fzero — The Matlab tool for solving Non-Linear equations Quick Solution with Matlab Now we solve for V numerically. fzero takes two arguments. (1) The first is a function_handle that accepts exactly 1 argument. (2) The second argument is an initial guess. Why did I use 30000 for the initial guess? A few slides ago I plotted this function and noted visually that the correct molar volume was around 30,000 cm3 mol . I just used fzero in OPEN mode. I’m telling Matlab to look near 30,000 cm3 mol but I place no restrictions on what range of molar volumes to try. >> Pc = 66.8; Tc = 416.15; R = 83.14; >> a = 0.42748 .* R^2 .* Tc .^ 2.5 ./ Pc; >> b = 0.08664 .* R .* Tc ./ Pc; >> T = 60 + 273.15; 5 >> P = @(V) R .* T ./ (V-b) - a ./ (V .* (V+b) .* sqrt(T)); >> root_finding_equation = @(V) 1 - P(V); >> V = fzero( root_finding_equation, 30000 ) V = 27431.8744533891 Script-file: find_methyl_chloride_P.m Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 7 / 16
  • 26. fzero — The Matlab tool for solving Non-Linear equations Quick Solution with Matlab Why did I use 30000 for the initial guess? A few slides ago I plotted this function and noted visually that the correct molar volume was around 30,000 cm3 mol . I just used fzero in OPEN mode. I’m telling Matlab to look near 30,000 cm3 mol but I place no restrictions on what range of molar volumes to try. We can also use fzero in CLOSED mode. The initial guess I provided is a 2-element array. It tells Matlab: ‘‘The root_finding_equation has a value of zero somewhere between 20000 and 40000’’ >> Pc = 66.8; Tc = 416.15; R = 83.14; >> a = 0.42748 .* R^2 .* Tc .^ 2.5 ./ Pc; >> b = 0.08664 .* R .* Tc ./ Pc; >> T = 60 + 273.15; 5 >> P = @(V) R .* T ./ (V-b) - a ./ (V .* (V+b) .* sqrt(T)); >> root_finding_equation = @(V) 1 - P(V); >> V = fzero( root_finding_equation, [20000 40000] ) V = 27431.8744533891 Script-file: find_methyl_chloride_P.m Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 7 / 16
  • 27. fzero — The Matlab tool for solving Non-Linear equations Quick Solution with Matlab We can also use fzero in CLOSED mode. The initial guess I provided is a 2-element array. It tells Matlab: ‘‘The root_finding_equation has a value of zero somewhere between 20000 and 40000’’ If I’m wrong and root_finding_equation does not in fact have a zero in this interval I’ll get an error >> Pc = 66.8; Tc = 416.15; R = 83.14; >> a = 0.42748 .* R^2 .* Tc .^ 2.5 ./ Pc; >> b = 0.08664 .* R .* Tc ./ Pc; >> T = 60 + 273.15; 5 >> P = @(V) R .* T ./ (V-b) - a ./ (V .* (V+b) .* sqrt(T)); >> root_finding_equation = @(V) 1 - P(V); >> V = fzero( root_finding_equation, [20000 25000] ) ??? Error using fzero (line 274) ??? The function values at the interval endpoints must differ in sign. Script-file: find_methyl_chloride_P.m Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 7 / 16
  • 28. Outline 1 Introduction The solution of a non-linear equation is a Root Finding Problem 2 Built-In Solution in Matlab: fzero 3 Built-In Solution in Excel: Solver Enabling the solver Using the solver Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 8 / 16
  • 29. Solving non-linear equations in Excel Excel has a tool called Solver that can perform two different tasks Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 9 / 16
  • 30. Solving non-linear equations in Excel Excel has a tool called Solver that can perform two different tasks 1 Set the value of a cell to a particular value by changing other cells. This is what we’re interested in right now. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 9 / 16
  • 31. Solving non-linear equations in Excel Excel has a tool called Solver that can perform two different tasks 1 Set the value of a cell to a particular value by changing other cells. This is what we’re interested in right now. 2 Minimize/maximize the value of a cell by changing other cells. We will come back to this one later. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 9 / 16
  • 32. Solving non-linear equations in Excel Excel has a tool called Solver that can perform two different tasks 1 Set the value of a cell to a particular value by changing other cells. This is what we’re interested in right now. 2 Minimize/maximize the value of a cell by changing other cells. We will come back to this one later. The Solver Add-In is not enabled by default, although on College of Engineering machines this has usually been done by the system administrator. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 9 / 16
  • 33. Solving non-linear equations in Excel Excel has a tool called Solver that can perform two different tasks 1 Set the value of a cell to a particular value by changing other cells. This is what we’re interested in right now. 2 Minimize/maximize the value of a cell by changing other cells. We will come back to this one later. The Solver Add-In is not enabled by default, although on College of Engineering machines this has usually been done by the system administrator. If you don’t see the following under the Data tab in Excel, then the next few slides show you how to get it. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 9 / 16
  • 34. Enable the Solver Add-In Go to the File tab and select Options Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 10 / 16
  • 35. Enable the Solver Add-In In the dialog that appears, select Add-Ins Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 10 / 16
  • 36. Enable the Solver Add-In In the next dialog, ensure that the Manage: box is showing Excel Add-ins and select Go... Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 10 / 16
  • 37. Enable the Solver Add-In In the next dialog, ensure that Solver Add-in is checked and then click OK Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 10 / 16
  • 38. Outline 1 Introduction The solution of a non-linear equation is a Root Finding Problem 2 Built-In Solution in Matlab: fzero 3 Built-In Solution in Excel: Solver Enabling the solver Using the solver Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 11 / 16
  • 39. Using Solver to Solve Non-linear equations A typical problem Find the molar volume of methyl chloride vapor such that at T = 60 ◦C the pressure is 1 bar. Use the Redlich-Kwong Equation of State: P = RT V − b − a V(V + b) √ T Variable Value Unit a 0.42748R2 Tc 2.5 Pc cm6 ·bar·K0.5 mol2 b 0.08664RTc Pc cm3 mol R 83.14 cm3 ·bar mol·K Tc 416.15 K Pc 66.8 bar Here’s a good start to solving the problem. The way I’ve set this spreadsheet up so far has a few features I’d like to point out. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 12 / 16
  • 40. Good practice with spreadsheets Formatting is important! Ask anyone who’s had to share a spreadsheet with their boss. Make what you’re doing clear! Use variable names Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 13 / 16
  • 41. Good practice with spreadsheets Formatting is important! Ask anyone who’s had to share a spreadsheet with their boss. Make what you’re doing clear! Use variable names Use superscripts and subscripts and the Symbol font to make variable names appear as close to their mathematical representation as possible. The keyboard shortcut CTRL + 1 is worth leaning to make this chore easier. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 13 / 16
  • 42. Good practice with spreadsheets Formatting is important! Ask anyone who’s had to share a spreadsheet with their boss. Make what you’re doing clear! Use variable names Use superscripts and subscripts and the Symbol font to make variable names appear as close to their mathematical representation as possible. The keyboard shortcut CTRL + 1 is worth leaning to make this chore easier. Keep parameters (constants) separate from values that you will be changing frequently. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 13 / 16
  • 43. Good practice with spreadsheets Formatting is important! Ask anyone who’s had to share a spreadsheet with their boss. Make what you’re doing clear! Use variable names Use superscripts and subscripts and the Symbol font to make variable names appear as close to their mathematical representation as possible. The keyboard shortcut CTRL + 1 is worth leaning to make this chore easier. Keep parameters (constants) separate from values that you will be changing frequently. Keep calculated values distinguished from user-manipulated values. In this example values I entered manually Are in an easily recognized font. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 13 / 16
  • 44. Good practice with spreadsheets Formatting is important! Ask anyone who’s had to share a spreadsheet with their boss. Make what you’re doing clear! Use variable names Use superscripts and subscripts and the Symbol font to make variable names appear as close to their mathematical representation as possible. The keyboard shortcut CTRL + 1 is worth leaning to make this chore easier. Keep parameters (constants) separate from values that you will be changing frequently. Keep calculated values distinguished from user-manipulated values. In this example values I entered manually Are in an easily recognized font. Include units!! Again, take the time to use superscripts. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 13 / 16
  • 45. Good practice with spreadsheets Use Names to Make Formulas Readable Make what you’re doing clear! The box to the left of the formula bar is for giving cells human-friendly names. Use it! Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 14 / 16
  • 46. Good practice with spreadsheets Use Names to Make Formulas Readable Make what you’re doing clear! The box to the left of the formula bar is for giving cells human-friendly names. Use it! Some names (like R) can’t be used. I usually append an underscore _ when this is the case. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 14 / 16
  • 47. Good practice with spreadsheets Use Names to Make Formulas Readable Make what you’re doing clear! The box to the left of the formula bar is for giving cells human-friendly names. Use it! Some names (like R) can’t be used. I usually append an underscore _ when this is the case. For variables with numerical subscripts, e.g., T1, enter the name as T_1. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 14 / 16
  • 48. Good practice with spreadsheets Use Names to Make Formulas Readable Make what you’re doing clear! The box to the left of the formula bar is for giving cells human-friendly names. Use it! Some names (like R) can’t be used. I usually append an underscore _ when this is the case. For variables with numerical subscripts, e.g., T1, enter the name as T_1. Look at how nice my formula for a is to read, it gives you a warm and fuzzy feeling doesn’t it? Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 14 / 16
  • 49. Good practice with spreadsheets Use Names to Make Formulas Readable Make what you’re doing clear! The box to the left of the formula bar is for giving cells human-friendly names. Use it! Some names (like R) can’t be used. I usually append an underscore _ when this is the case. For variables with numerical subscripts, e.g., T1, enter the name as T_1. Similarly, I can also tell by looking at the cell formula that this is the RK Equation of State. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 14 / 16
  • 50. Setting up the problem for Solver Now I’m going to define my root-finding cell. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 15 / 16
  • 51. Setting up the problem for Solver Now I’m going to define my root-finding cell. And now open up the Solver (it’s in the Data tab). Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 15 / 16
  • 52. The Solver dialog. The Solver dialog has a lot going on inside of it. For now, we only need to use the top three rows. Set Objective This is the address of the cell you want to solve for. We want the Difference: cell to assume a value of 0. Click that cell and its address will appear in the Set Objective box. To: Here is where we decide between root-finding (Value of:) and min/max problems. We want the difference between the actual pressure and 1 bar to be 0, so Value of: should be selected with a value of 0 in the box. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 16 / 16
  • 53. The Solver dialog. Now tell Solver which cells to manipulate in order to make the difference 0. Click on the Range Selector Tool Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 16 / 16
  • 54. The Solver dialog. We want to change the molar volume. Click it Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 16 / 16
  • 55. The Solver dialog. We’re ready! Click Solve Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 16 / 16
  • 56. The Solver dialog. All done. Notice the volume has changed to 27431.9, and the Difference: is 8.48e-07. Pretty close to zero. If that’s not close enough, we can tweak the tolerance in the Solver. Che 310 | Chapra 5.1–5.2 | Intro to Root-Finding 4 — Intro to NLEs September 19, 2017 16 / 16