Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Procedure a. Login to a computer.Start Microsoft Excel. Open a blank spreadsheet. Save it to your area (VBALabS.xlsm) b. Many times in petroleum engineering it
Procedure a. Login to a computer.Start Microsoft Excel. Open a blank spreadsheet. Save it to your area (VBALabS.xlsm) b. Many times in petroleum engineering it is desirable to evaluate an integral. Sometimes a direct analytic solution is unavailable, but the base function is known. In these cases we want to numerically evaluate the integral. Implement the following algorithnes as a Visual Basic function. Do not write the algorithm. Write VB code. For the first part of the assignment (a-c) use Single precision numbers, not Double Trapezoidal Rule Returns an estimate of the integral of a function Input: left limit a, right limit b, and positive integer n (how many intervals). h- (b-a)n Integral0 xold- a For i-1, 2 xnew a +i*h Integral-Integral + h*(f(xoldMxnew))/2 xold xnew Composite Simpson's Rule Returns an estimate of the integral of a function Input: a, b(limits), and positive even integer n (how many intervals) h (b-a)n even sum- odd sum-0 For i-1, 2, x-ati h if i is even even sum- even sumx) else odd sum-odd sumx) Integral- h (suml+2"even sum+4 odd sumy3 You winced to use the mod operator Remember mod returns the remainder of integer division. retuns I, etc. to determine whether a number is even or odd. 16 Mod 2 returms 0, 17 Mod 2 The input to the functions will be a, b, and the number of intervals. One very weak point of Visual Basic is its inability to pass function names as arguments. Thus, in VBA you noed to rewrite fix) for every function you need to integrate. With many other languages, you would just pass a new function name to the integrating function. c. Create a test function fx. This will be a function that can be easily integrated Procedure a. Login to a computer.Start Microsoft Excel. Open a blank spreadsheet. Save it to your area (VBALabS.xlsm) b. Many times in petroleum engineering it is desirable to evaluate an integral. Sometimes a direct analytic solution is unavailable, but the base function is known. In these cases we want to numerically evaluate the integral. Implement the following algorithnes as a Visual Basic function. Do not write the algorithm. Write VB code. For the first part of the assignment (a-c) use Single precision numbers, not Double Trapezoidal Rule Returns an estimate of the integral of a function Input: left limit a, right limit b, and positive integer n (how many intervals). h- (b-a)n Integral0 xold- a For i-1, 2 xnew a +i*h Integral-Integral + h*(f(xoldMxnew))/2 xold xnew Composite Simpson's Rule Returns an estimate of the integral of a function Input: a, b(limits), and positive even integer n (how many intervals) h (b-a)n even sum- odd sum-0 For i-1, 2, x-ati h if i is even even sum- even sumx) else odd sum-odd sumx) Integral- h (suml+2"even sum+4 odd sumy3 You winced to use the mod operator Remember mod returns the remainder of integer division. retuns I, etc. to determine whether a number is even or odd. 16 Mod 2 returms 0, 17 Mod 2 The input to the functions will be a, b, and the number of intervals. One very weak point of Visual Basic is its inability to pass function names as arguments. Thus, in VBA you noed to rewrite fix) for every function you need to integrate. With many other languages, you would just pass a new function name to the integrating function. c. Create a test function fx. This will be a function that can be easily integrated
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started