[ Pobierz całość w formacie PDF ]
at points stored in the array xi. Parameters x, y, and p stand for the breakpoints, values of
s(x), and values of s'(x) at the breakpoints of s(x), respectively. The output parameter yi is the
array of values of s(x) at points stored in the array pts which is defined as the union of the
arrays linspace(x(k), x(k+1)), k = 1, 2, & , n 1, where n = length(x).
Hint: You may wish to use function Hermpol discussed in Section 5.3.
22. The nodes {xk} of the Newton Cotes formulas of the open type are defined as follows
xk = a + (k 1/2)h, k = 1, 2, & , n 1, where h = (b a)/(n 1). Write MATLAB
function [s, w, x] = oNCqf(fun, a, b, n, varargin) that computes an approximate value s of
45
the integral of the function that is represented by the string fun. Interval of integration is
[a, b] and the method used is the n-point open formula whose weights and nodes are
are stored in the arrays w and x, respectively.
23. The Fresnel integral
x
iÀ t2
f(x) =
+"exp( 2 )dt
is of interest in several areas of applied mathematics. Write MATLAB function [fr1, fr2] =
Fresnel(x, tol, n) which takes a real array x, a two dimensional vector tol holding the relative
and absolute tolerance for the error of the computed integral (see MATLAB help file for the
function quad8), and a positive integer n used in the function Romberg and returns numerical
approximations fr1 and fr2 of the Fresnel integral using each of the following methods
(i) quad8 with tolerance tol = [1e-8 1e-8]
(ii) Romberg with n = 10
Compute Fresnel integrals for the following values of x = 0: 0.1:1.To compare the
approximations fr1 and fr2 calculate the number of decimal places of accuracy
dpa = log10(norm(fr1 fr2, 'inf ')). For what choices of the input parameters tol and n the
number dpa is greater than or equal to 13? The last inequality must be satisfied for all values
x as defined earlier.
24. Let us assume that the real-valued function f(x) has a convergent integral
"
+"f (x)dx .
Explain how would you compute an approximate value of this integral using function
Gquad2 developed earlier in this chapter? Extend your idea to convergent integrals of the
form
"
+"f(x)dx.
- "
25. The following integral is discussed in [3], p. 317
1
dx
J = .
+"
x4 + x2 + 0.9
- 1
To compute an approximate value of the integral J use
(i) MATLAB functions quad and quad8 with tolerance tol = [1e-8 1e-8]
(ii) functions Romberg and Gquad1 with n = 8.
Print out numerical results using format long. Which method should be recommended for
numerical integration of the integral J? Justify your answer.
46
26. The arc length s of the ellipse
x2 y2
+ = 1
a2 b2
from (a, 0) to (x, y) in quadrant one is equal to
¸
s = b 1 - k2 sin2 tdt
+"
where k2 = 1 (a/b)2 , a d" b, and ¸ = arccos(x / a) = arcsin(y / b).
In this exercise you are to write MATLAB function [sR, sq8] = arcell(a, b, x, n, tol) that
takes as the input parameters the semiaxes a and b and the x coordinate of the point on the
ellipse in quadrant one and returns an approximate value of the arc of ellipse from (a, 0) to
(x, y) using functions Romberg, described in this chapter, and the MATLAB function
quad8. The fourth input parameter n will be used by the function Romberg. The fifth input
parameter tol is optional and it holds the user supplied tolerances for the relative and absolute
errors in the computed approximation sq8. If tol is not supplied, the default values for
tolerances should be assigned. For more details about using this parameter, type help quad8
in the Command Window. Your program should also work for ellipses whose semiaxes are
not restricted to those in the definition of the parameter k2. Test your function for the
following values of the input parameters
(i) a = 1, b = 2, x = 1: -0.1: 0, n = 10, tol = [ ]
(ii) a = 2, b = 1, x = 2: -0.2: 0, n = 10, tol = [ ]
(iii) a = 2, b = 1, x = 0: -0.2: -2, n = 10, tol = [ ]
Note that the terminal points (x, y) of the third ellipse lie in quadrant two.
27. Many of the most important special functions can be represented as the Dirichlet average F
of a continuous function f (see [1] )
1
1
1 2
[ Pobierz całość w formacie PDF ]