1.Programming Example
(1) Calculate the sum of the series, compute the power seriesxn/n!(n takes values from0 to∞) sum function
Program:
syms n x
f=x^n/factorial(n)
symsum(f,n,0,inf)
Running Result:
f =
x^n/factorial(n)
ans =
exp(x)
(2) Calculate the Taylor expansion, computef=exp(x) atx=1 with5th order approximate Taylor expansion
syms x y
f=exp(x)
taylor(f,x,’ExpansionPoint’,1,’Order’,5)
Running Result:
f =
exp(x)
ans =
exp(1) + exp(1)*(x – 1) + (exp(1)*(x – 1)^2)/2 + (exp(1)*(x – 1)^3)/6 + (exp(1)*(x – 1)^4)/24
2. Special Note
symsum is used to calculate the sum of series functions, similar to summing sequences (see article 77Matlab Quick Start Basics 77: Summing Sequences, Applications of Geometric and Arithmetic Series), a series is a function that connects the terms of a sequence with addition, typical series include positive series, alternating series, power series, Fourier series, etc.
The Symbolic Math ToolboxMatlab Quick Start 54: Symbolic Math Toolbox provides two summation functions,sum calculates the sum of elements in a matrix or vector, summing along a certain dimension,symsum calculates the sum of symbolic series, summing over a certain index, for definite series summation,symsum is faster thansum for solving, for uncertain series summation, onlysymsum can be used.
taylor is used to compute the Taylor expansion, also known as the Taylor series, the concept and expression of the Taylor series can be reviewed online, placing the formula editor here is too difficult.
[I speak for myself:freexyn, a minimalist and free style]
Related content recommendations
Matlab Quick Start 80: Simple and Understandable | Limits and Derivatives, Partial Derivatives, Higher Order Derivatives, Differential Operations
Matlab Quick Start Short Article 79: Usage of Functions Related to Permutations and Combinations
Matlab Quick Start Notes 78: Conic Sections and Equations, Parabolas, Ellipses, Hyperbolas Equations and Graphs
Matlab Programming Basics 76: Four Major Functions for Symbolic Computation to Solve Polynomial Expansion/Decomposition/Simplification Problems | Reject Manual Derivation
Matlab Quick Start Short Article 74: Coordinate System Transformation, Mutual Conversion of Rectangular Coordinates, Polar Coordinates, and Spherical Coordinates
Matlab Quick Start Short Article 37: Concepts, Classifications, and Creation Methods of DateTime Types, Duration Type, calendarDuration Type
Matlab Q&A 26: Recent Issues and Solutions Encountered in Learning Course 45 Deep Learning Programming
Concise Algorithm Program Example 9: Least Squares Method: Transforming Nonlinear Problems into Linear Problems for Processing
End