Question: Problem #6: please refer to the picture with excercise 5, to write a VBA code that correspond with the case: Write a VBA program for
Problem #6: please refer to the picture with excercise 5, to write a VBA code that correspond with the case: 
Write a VBA program for problem 5 that implements *either* the Newton-Raphson or Secant method to solve for the root. Use a subroutine to call your function, and display the result in a message box. You can use the pseudocode below to get you started.
FUNCTION NR(x) MaxIter = 100 es = machine_epsilon_double * 100
DO IF i > MaxIter THEN OUTPUT "Max. iterations exceeded in function NR" EXIT FUNCTION END IF x_new = x - f(x) / f_prime(x) ea = (x_new - x) / x_new * 100 x = x_new i = i + 1 LOOP WHILE |ea| >= es
NR = x
END FUNCTION
Problem #5 A well-mixed lake receives 200 grams of pollutant per day from atmospheric fallout (W). The volume (V) of the 'ake is 25,000 cubic meters. The rate of outflow from the lake (Q) is 300 m3/d. In the lake, the pollutant degraacs at the following rate: rate of pollutant degradation =k*cV wherek is a first-order pollutant degradation coefficient and c is the pollutant concentration in units of grams per cubic meter. The value of k is 0.1 day-1. We wish to find the steady-state pollutant concentration in the lake. Step 1 - Setup a mass balance equation for the pollutant, where: inputs = outputs then set it equal to zero, Step 2 - Plot f(c) vs. c to find an approximate value of the root. This will be your initial guess(es) Step 3 - Setup 2 tables in excel, one that will find the solution using Newton-Raphson, and one that uses the secant method. Step 4 - Verify your answers! Show verification on the worksheet. Problem #5 A well-mixed lake receives 200 grams of pollutant per day from atmospheric fallout (W). The volume (V) of the 'ake is 25,000 cubic meters. The rate of outflow from the lake (Q) is 300 m3/d. In the lake, the pollutant degraacs at the following rate: rate of pollutant degradation =k*cV wherek is a first-order pollutant degradation coefficient and c is the pollutant concentration in units of grams per cubic meter. The value of k is 0.1 day-1. We wish to find the steady-state pollutant concentration in the lake. Step 1 - Setup a mass balance equation for the pollutant, where: inputs = outputs then set it equal to zero, Step 2 - Plot f(c) vs. c to find an approximate value of the root. This will be your initial guess(es) Step 3 - Setup 2 tables in excel, one that will find the solution using Newton-Raphson, and one that uses the secant method. Step 4 - Verify your answers! Show verification on the worksheet
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
