<Span style = "font-size: 18px;"> % function integration problem MATLAB implementation % function extreme point % 1. minimum point of a mona1 function % instance: F (x) = [email protected] (x) X. ^ 3-x. ^ 2-x + 1X = fminbnd (F,-) % use the fminbnd () function to calculate the minimum value of a mona1 function. The parameters are f (x) function value corresponding to the interval short point y = f (x) % minimum point % result % F = % @ (x) X. ^ 3-x. ^ 2-x + 1% x = % 1.0000% y = % 3.5776e-10% 2. Calculate the maximum value of a single-element function: either-f (x) or 1/f (x) for example: calculate the maximum value [email protected] (x)-X of x ^ 4-6x ^ 2 + 8x + 17 in the range [1, 3. ^ 4-6. ^ 2 + 8 * x + 17% the minimum value of-f (x) is the maximum value of f (x) x = Fminbnd (F, 1, 3) y =-f (x) % result % F = % @ (x)-X. ^ 4-6. ^ 2 + 8 * x + 17% x = % 3.0000% y = % 75.9952% 2. There are two main methods to solve the minimum point of a multivariate function: simple downhill method and quasi-Newton method % x = fminsearch (fun, X0) Simple downhill Method for Solving the multivariate function extreme points in the simplest format % [x, fval, exitflag, output] = fminsearch (fun, x0, ptionas, P1, p2 ...) full format % x = fminunc (fun, X0) simple form of quasi-Newton method % [x, fval, exitflag, output, grad, Hessian] = fminunc (fun, X0) simple Form of quasi-Newton method % specific instance % solution function f (x) = 100 (x2-3x1 ^ 2) ^ 2 + (1-2x1) ^ 2 Minimum value: [email protected] (x) 100 *( X (2)-3 * x (1) ^ 2) ^ 2 + (1-2 * x (1) ^ 2 [x, fval] = fminsearch (Y, [-3, 3]) % result % Y = % @ (x) 100 * (X (2)-3 * x (1) ^ 2) ^ 2 + (1-2 * x (1 )) ^ 2% x = % 0.5000 0.7500% fval = % 5.4048e-10% % Function Points % 1. The value points of the mona1 function % Function Points are equal to the area enclosed by the corresponding function graph % trapezoid numerical point function trapz () calculate the sum of area of several trapezoid to approximate the integral % instance of the function. % calculate the integral x = [-Pi: 0.001: Pi] of SiNx from-pi to pi. % The smaller the spacing between independent variables, the more accurate the integral Result Y = sin (x); Area = trapz (x, y) % run the result (SiNx is a odd function, points are obtained in the symmetric interval. The result is 0) % area = %-1.7169e-08% 2. Points are expressed as points in the simps' Number % simps' numerical points Quad () and the coz numerical points quadl () The result is more accurate than the numerical integral function trapz () of the trapezoid method. % q = Quad ('f (x) ', x1, x2) indicates that the relative error of the integral % integral of function f (x) from the integral range [x1, x2] is within the range of 1-3. The 'f (x) 'in the input parameter is a string, indicating the expression of the integral function % when the input is a vector, the return value must be in the vector form % q = Quad ('f (X) ', x1, x2, Tol) Integral Error in tol range % q = Quad ('f (x)', x1, x2, Tol, trace) when the input trace parameter is not 0, the entire process of integration is implemented in the form of a dynamic dot graph. % q = Quad ('f (x) ', x1, x2, Tol, trace, p1, p2 ...) allow the input parameter P1 and P2 to directly lose to function f (). In this case, when tracehe % ToL is the default value, enter an empty matrix % instance: calculate the integral Quad ('x. ^ 2 + X-5 ', 29.1667%) % result % ans = % coz numerical points: quadl () function, syntax is similar to the QAD () of the Simpson numerical point function % instance: calculate the integral quadl ('x. 2 + x-5 ', 29.1667%) % result % ans = % multi-value points, points again based on hospital points, such as dual points, triple points, etc. % 1) dual points: Use dblquad () function, in the order of dxdy, X is the inner point variable, and Y is the outer point variable. % Calculate the inner point variable first and calculate the outer point variable % based on the intermediate result of the inner point. Usage: % q = dblquad (fun, Minx, Maxx, miny, Maxy) dual point % q = dblquad (fun, Minx, Maxx, miny, and TOL) of the computing function on [Minx, Maxx, miny, and Maxy) toL is used to specify the absolute computing accuracy % instance: Calculate the function f = Ysin (x) + xcos (y) in the rectangle area in [Pi, 2 * Pi, 0, pi] dual point [email protected] (x, y) y * sin (x) + x * Cos (y); q = dblquad (F, PI, pI * 9.8696%, Pi) % result % q = %-2) the triple integral is implemented using the triplequad () function, similar to the Double Integral dblquad, just add one more DZ </span>
Basic Learning of MATLAB ---------------- extreme values and integral problems of functions MATLAB implementation