Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 26.1, Problem 4E
Program Plan Intro
To prove the flows in a network form a convex set.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
We have learned the mid-point and trapezoidal rule for
numercial intergration in the tutorials. Now you are asked to
implement the Simpson rule, where we approximate the
integration of a non-linear curve using piecewise quadratic
functions.
Assume f(x) is continuous over [a, b] . Let [a, b] be
divided into N subintervals, each of length Ax, with
endpoints at P = x0, x1, x2,..
Xn,..., XN. Each
interval is Ax = (b − a)/N.
The equation for the Simpson numerical integration rule is
derived as:
f f(x) dx
N-1
Ax [ƒ(x0) + 4 (Σ1,n odd f(xn))
ƒ(x₂)) + f(xx)].
N-2
+ 2 (n=2,n even
Now complete the Python function InterageSimpson (N, a,
b) below to implement this Simpson rule using the above
equation.
The function to be intergrate is ƒ(x) = 2x³ (Already
defined in the function, no need to change).
Let f be a flow of flow network G and f' a flow of residual network Gf . Show that f +f' is a flow of G.
We have learned the mid-point and trapezoidal rule for numercial intergration in the tutorials. Now you are asked to implement the Simpson rule, where we approximate the integration of a non-linear curve using piecewise quadratic functions.
Assume f(x) is continuous over [a, b]. Let [a, b] be divided into N subintervals, each of length Ax, with endpoints at P = x0, x1,x2,..., X., XN. Each interval is Ax = (b − a)/N.
The equation for the Simpson numerical integration rule is derived as:
f f(x)dx ≈
[ƒ(x0) + 4 (EN-1,n odd S(x)) + 2 (Σ2²n even f(x)) + f(XN)].
Now complete the Python function InterageSimpson (N, a, b) below to implement this Simpson rule using the above equation.
The function to be intergrate is f(x) = 2x³ (Already defined in the function, no need to change).
*Complete the function given the variables N, a,b and return the value as "TotalArea"."
"Don't change the predefined content' only fill your code in the region *YOUR CODE""
from math import *
def InterageSimpson (N, a,…
Chapter 26 Solutions
Introduction to Algorithms
Ch. 26.1 - Prob. 1ECh. 26.1 - Prob. 2ECh. 26.1 - Prob. 3ECh. 26.1 - Prob. 4ECh. 26.1 - Prob. 5ECh. 26.1 - Prob. 6ECh. 26.1 - Prob. 7ECh. 26.2 - Prob. 1ECh. 26.2 - Prob. 2ECh. 26.2 - Prob. 3E
Ch. 26.2 - Prob. 4ECh. 26.2 - Prob. 5ECh. 26.2 - Prob. 6ECh. 26.2 - Prob. 7ECh. 26.2 - Prob. 8ECh. 26.2 - Prob. 9ECh. 26.2 - Prob. 10ECh. 26.2 - Prob. 11ECh. 26.2 - Prob. 12ECh. 26.2 - Prob. 13ECh. 26.3 - Prob. 1ECh. 26.3 - Prob. 2ECh. 26.3 - Prob. 3ECh. 26.3 - Prob. 4ECh. 26.3 - Prob. 5ECh. 26.4 - Prob. 1ECh. 26.4 - Prob. 2ECh. 26.4 - Prob. 3ECh. 26.4 - Prob. 4ECh. 26.4 - Prob. 5ECh. 26.4 - Prob. 6ECh. 26.4 - Prob. 7ECh. 26.4 - Prob. 8ECh. 26.4 - Prob. 9ECh. 26.4 - Prob. 10ECh. 26.5 - Prob. 1ECh. 26.5 - Prob. 2ECh. 26.5 - Prob. 3ECh. 26.5 - Prob. 4ECh. 26.5 - Prob. 5ECh. 26 - Prob. 1PCh. 26 - Prob. 2PCh. 26 - Prob. 3PCh. 26 - Prob. 4PCh. 26 - Prob. 5PCh. 26 - Prob. 6P
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Given a flow network as below with S and T as source and sink (destination). The pair of integers on each edge corresponds to the flow value and the capacity of that edge. For instance, the edge (S.A) has capacity 16 and currently is assigned a flow of 5 (units). Assume that we are using the Ford-Fullkerson's method to find a maximum flow for this problem. Fill in the blanks below with your answers. a) An augmenting path in the corresponding residual network is Note: give you answer by listing the vertices along the path, starting with S and ending with T, e.g., SADT (note that this is for demonstration purpose only and may not be a valid answer), with no spaces or punctuation marks, i.e., no commas "," or full stops ".". If there are more than one augmenting path, then you can choose one arbitrarily. b) The maximum increase of the flow value that can be applied along the augmenting path identified in Part a) is c) The value of a maximum flow is Note: your answers for Part b) and Part…arrow_forwardLet X = {1,2,..., 100} , and consider two functions f: X → R and g : X → R. The Chebyshev metric of f and g is given by: d(f, g) = max |f(x) – g(x)| Write a functiond (f,g) that calculates the Chebyshev metric of any two functions f and g over the values in X.arrow_forwardLet f ∈ C+ 2π with a zero of order 2p at z. Let r>p and m = n/r. Then there exists a constant c > 0 independent of n such that for all nsufficiently large, all eigenvalues of the preconditioned matrix C−1 n (Km,2r ∗ f)Tn(f) are larger than c.arrow_forward
- Let X= (-3,-2,-1,0, 1}. Let f: X→ N by f(x) = [7z+11: The range of the function isarrow_forwardLet X = {1,2,..., 100} , and consider two functions f : X → R and g: X → R. The Chebyshev metric of f and g is given by: d(f,g) = max|f(x) – g(x)| IEX Write a function d (f,g) that calculates the Chebyshev metric of any two functions f and g over the values in X.arrow_forward3 Let f be a flow of flow network G and f' a flow of residual network Gf. Show that f+f' is a flow of G.arrow_forward
- Let f(x) = x¹ Hx-x¹b, where H and b are constant, independent of x, and H is symmetric positive definite. Given vectors x0) and p0), find the value of the scalar a that minimizes f(x0) + ap0)). This is the formula for the stepsize ak in the linear conjugate gradient algorithm.arrow_forwardConsider a function f : S→ T defined by f(n) = n², where the domain is the set of consecutive integers S = {-7,..., -2, -1, 0, 1, 2, ..., 7} and the range is the set of consecutive squares T = {-64,...,-9, -4,-1,0, 1, 4, 9, ..., 64}. Which one of the following choices correct describes f? O one-to-one, but NOT onto Oonto, but NOT one-to-one O one-to-one and onto O neither one-to-one nor onto O none of thesearrow_forwardAlgorithm: Network Flow(Maximu Flow, Ford-Fulkerson) and Application of Flow (Minimum Cuts, Bipartite Matching) Consider a flow network and an arbitrary s, t-cut (S, T). We know that by definition s must always be on the S "side" of a cut and t is always going to be on the T "side" of the cut. Obviously, this is true for any cut. Now, consider minimum cuts. This is obviously still true for s and t, but what about other vertices in the flow network? Are there vertices that will always be on one side or the other in every minimum cut? Let's define these notions more concretely. • We say a vertex v is source-docked if v ∈ S for all minimum cuts (S, T). • We say a vertex v is sink-docked if v ∈ T for all minimum cuts (S, T). • We say a vertex v is undocked if v is neither source-docked nor sink-docked. That is, there exist minimum cuts (S, T) and (S 0 , T0 ) such that v ∈ S and v ∈ T' Give an algorithm that takes as input a flow network G and assigns each vertex to one of the three…arrow_forward
- Given functions f:R → R and g: R → R. Suppose that go f turns out as go f(x) = (x2 + 7]. Identify the g(x) and f(x) that produce the go f(x) as stated. Also, plot g(x) and f(x).arrow_forward1. Let f(x₁, x₂) = x₁ cos(x₂) e¯*₁. What is the gradient Vf(x) of f?arrow_forwardProve that in a given vector space V, the zero vector is unique. Suppose, by way of contradiction, that there are two distinct additive identities 0 and u,. Which of the following statements are then true about the vectors 0 and u,? (Select all that apply.) O The vector 0 + u, is not equal to u, + 0. O The vector 0 + u, is equal to un: O The vector 0 + u, is not equal to 0. O The vector 0 + u, does not exist in the vector space V. O The vector 0 + u, is equal to 0. O The vector o + u, is not equal to u: Which of the following is a result of the true statements that were chosen and what contradiction then occurs? O The statement u, + o 0, which contradicts that u, is an additive identity. O The statement u, +0 # 0 + u, which contradicts the commutative property. O The statement u, = 0, which contradicts that there are two distinct additive identities. O The statement u, + 0 U, which contradicts that O is an additive identity. O The statement u, + 0 + 0, which contradicts that u, must…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole