1.Programming Example
(1) Calculate the indefinite integral of the function f(x,y)=2x + 2ny with respect to x.
Program:
syms x y n
f = 2*x + 2*n*y
int(f,x)
Running Result:
f =
2*x + 2*n*y
ans =
x^2 + 2*n*y*x
(2) Calculate the definite integral of the function f(x)=sin(cos(x)) over the interval [0,1].
syms x
f=sin(cos(x))
a=int(f,x,0,1)
double(a)
Running Result:
f =
sin(cos(x))
a =
int(sin(cos(x)), x, 0, 1)
ans =
0.7386
2.Explanation
Integral calculations use the int function, which can solve both definite and indefinite integrals using symbolic computation. Compared to differentiation, integral calculations are more complex and may encounter difficulties, such as: integrals may not exist over closed intervals, integrals may return unknown functions, or the software may fail to find the integral even if it exists. The software can compute integrals on more powerful computers, but may exceed memory limits or require more computation time on the current machine.
It is important to note that this function is not omnipotent; if int cannot solve for a closed integral result, it will return an unsolvable form. However, it is effective in most cases. If you encounter complex integral forms in practical problems, feel free to leave a message for discussion.
For definite integrals, the int function restricts the range of the integral variable to the limits of integration. Moreover, if the limits of integration [a,b] are not numerical, it defaults to a<=b. Some functions may not have explicit solutions for indefinite integrals, and attempting to find definite integrals may also yield no explicit solution. If necessary, numerical methods can be used to compute approximate values.
freexyn, a minimalist and free-spirited style.
Related Content Recommendations
Matlab Quick Literacy 80: Simple and Understandable | Limits and Derivatives, Partial Derivatives, Higher-Order Derivatives, Differential Calculations
Matlab Quick Notes 79: Usage of Functions Related to Permutations and Combinations
Matlab Quick Notes 78: Conic Sections and Equations, Parabolas, Ellipses, Hyperbolas Equations and Graphs
MATLAB Quick Exercises 4.6.1 Annotating Coordinates on Graphs: Zero Point Coordinates | One Line of Code to Solve
End