Question

In: Advanced Math

I need to solve math problem by using freemat or mathlab program. However, I can't understand...

I need to solve math problem by using freemat or mathlab program. However, I can't understand how to make a code it.
This is one example for code ( freemat )

format long

f = @(x) (x^2) % define f(x) = x^2
a=0
b=1
N=23
dx = (b-a)/N % dx = delta_x

1. Methods:

(a) Left Rectangular Rule also known as Lower sum.

(b) Right Rectangular Rule also know as upper sum.

(c) Midpoint Rule

(d) Trapezoid Rule

(e) Simpson Rule

2. Evaluate

Integral {4/(x^2 + 1)} (Upper bound 1 Lower bound 0)

Solutions

Expert Solution

1. (a) Left Rectangular Rule : The left rectangular rule is the sum given by

for the partition

  

where

  

In case of uniform partition size we have

Create a MATLAB function file called Left_Rectangular_Rule.m and paste the code given below.

function L = Left_Rectangular_Rule(f,a,b,n)
%LEFT_RECTANGULAR_RULE Approximate the integral value using Left Rectangle
% Rule
% Input:
% f - Function handle of the integrand f(x)
% a - Lower limit of integeration
% b - Upper limit of integeration
% n - Number of partitions of interval [a,b]
% Output:
% L - Left Rectangle Rule Approximation of integral

% Calculate the step size delta x
dx = (b-a)/n;

% Calculate the Left Rectangle sum of the partition of [a,b]
L = dx*sum(f(a:dx:b-dx));

end

(b) Right Rectangular Rule : The Right Rectangular Rule is given by the sum

  

for the partition

  

where

  

In case of uniform partition size we have

Create a MATLAB function file called Right_Rectangular_Rule.m and paste the code given below.

function R = Right_Rectangular_Rule(f,a,b,n)
%Right_RECTANGULAR_RULE Approximate the integral value using Right Rectangle
% Rule
% Input:
% f - Function handle of the integrand f(x)
% a - Lower limit of integeration
% b - Upper limit of integeration
% n - Number of partitions of interval [a,b]
% Output:
% R - Right Rectangle Rule Approximation of integral

% Calculate the step size delta x
dx = (b-a)/n;

% Calculate the Right Rectangle sum of the partition of [a,b]
R = dx*sum(f(a+dx:dx:b));

end

(c)  Midpoint Rule : The mid point rule is the sum given by

  

where

are the mid points of the partitions of the interval

where

  

In case of uniform partition size we have

Create a MATLAB function file called MidPoint_Rule.m and paste the code given below.

function M = MidPoint_Rule(f,a,b,n)
%MIDPOINT_RULE Approximate the integral value using Mid point
% Rule
% Input:
% f - Function handle of the integrand f(x)
% a - Lower limit of integeration
% b - Upper limit of integeration
% n - Number of partitions of interval [a,b]
% Output:
% M - Mid Point Rule Approximation of integral

% Calculate the step size delta x
dx = (b-a)/n;

% Calculate the mid points of the partitions of [a,b]
m = ((a:dx:b-dx) + (a+dx:dx:b))/2;

% Calculate the Mid Point Rule sum of the partition of [a,b]
M = dx*sum(f(m));

end

(d) Trapezoidal Rule : The trapezoidal rule is given by the sum

for the partition

  

where

  

In case of uniform partition size we have

Create a MATLAB function file called Trapezoidal_Rule.m and paste the code given below.

function T = Trapezoidal_Rule(f,a,b,n)
%TRAPEZOIDAL_RULE Approximate the integral value using Trapezoidal Rule
% Input:
% f - Function handle of the integrand f(x)
% a - Lower limit of integeration
% b - Upper limit of integeration
% n - Number of partitions of interval [a,b]
% Output:
% M - Trapezoidal Rule Approximation of integral

% Calculate the step size delta x
dx = (b-a)/n;

% Calculate the Trapezoidal Rule sum of the partition of [a,b]
T = (dx/2)*sum(f(a:dx:b-dx)+ f(a+dx:dx:b));

end

2. We can now approximate the integral value

  

using the 4 functions we have defined.

The results of the approximations are given below.

The exact value of the integral is


Related Solutions

I have the answer for this problem but I need to solve it using Excel's PV...
I have the answer for this problem but I need to solve it using Excel's PV function for both products and I cannot seem to figure it out. What would I insert for each portion of the equation into excel? It has been answered on another question as number 2. http://www.chegg.com/homework-help/questions-and-answers/lou-barlow-divisional-manager-sage-company-opportunity-manufacture-sell-one-two-new-produc-q12342389?trackid=297667da&strackid=464d9914&ii=8
I need the calculation of this problem. This question has solution but I can't figure the...
I need the calculation of this problem. This question has solution but I can't figure the answer calculation Again I need calculation probably last line Question : On a certain standardized test The mean is 51 The standard deviation is 15 Exactly 66% of the people who took the test scored higher than Mr. Peterson. Find a, b, and c such that Mr. Peterson's score is approximately a + b ⋅ Φc(d) Do not make a continuity correction. What is...
I am trying to plot a difficult function in MATLAB, however I need to understand the...
I am trying to plot a difficult function in MATLAB, however I need to understand the basics first. I am trying to plot n=0 for x=0:0.01:2pi n=n+1 y(n)=sin(x) end I beleive what this says, is that I want to plot sin(x) over a full period hence from o to 2pi, and I beleive the 0.01 is the incremenation along the x-axis. I am not sure what my n is doing Could smeone please graph this for me with the MATLAB...
My Java program keeps "running." I know I need to close a "loop" but I can't...
My Java program keeps "running." I know I need to close a "loop" but I can't find it. I'm learning how to code. This is confusing for me. import java.util.Scanner; import java.util.ArrayList; public class SteppingStone4_Loops {    public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String recipeName = ""; ArrayList<String> ingredientList = new ArrayList(); String newIngredient = ""; boolean addMoreIngredients = true; System.out.println("Please enter the recipe name: "); recipeName = scnr.nextLine();    do {    System.out.println("Would you...
I need to write a program and can't seem to make it run properly. Someone can...
I need to write a program and can't seem to make it run properly. Someone can help with the coding? It's with python Thanks! Here is the program: The rules of Shut the Box are as follows (abbreviated version): + You have two 5-sided die + You have 5 wooden blocks (labeled 1 through 5) + Each turn, you roll the dice and knock down the blocks corresponding to the number on each die + You have to knock down...
Graphically solve the following problem. You need not show me the graph. However, you would need...
Graphically solve the following problem. You need not show me the graph. However, you would need to draw one to solve the problem correctly. You would need to indicate all the corner points clearly. Solve mathematically to identify the intersection points. Maximize profit = 8 x1 + 5x2    Subject to    x1 + x2 <=10 x1 <= 6 x1, x2 >= 0 a. What is the optimal solution? (You may utilize QM for Windows to answer b to d)...
Please do the math by hand, do not use a program, I need to see the...
Please do the math by hand, do not use a program, I need to see the procedure, the answer itself is less important. Comparison of peak expiratory flow rate (PEFR) before and after a walk on a cold winter's day for a random sample of 9 asthmatics. Use the following data to determine if the patients conditioned changed after a walk. Present your results and make some interpretations. Subject Before After 1 312 300 2 242 201 3 340 232...
please explain milio's framework for prevention i can't understand it
please explain milio's framework for prevention i can't understand it
Solve this word problem using step by step procedure: The math department at a local university...
Solve this word problem using step by step procedure: The math department at a local university has customarily advised students to purchase Calculator A. The manufacturer has recently released a new model, Calculator B, which is reputed to be more user-friendly. The faculty decided to determine if there is a difference in the time required to perform a certain common statistical calculation. Twelve students chosen at random are given drills with both calculators so that they are familiar with the...
i believe i understand sigma and pi for covalent bonds... however do not understand sigma and...
i believe i understand sigma and pi for covalent bonds... however do not understand sigma and pi bonds for ionic bonds. so   what are properties of ionic sigma pi bonds...can you/we sketch them. what makes them different from convalent sigma pi bonds?   TY
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT