# Indifference Computer Experiment for Mathematical Identification of Two Variables

Authors: Jianxi Yu
Journal: Wireless Communications and Mobile Computing
 (2022)

---

## Abstract

In order to understand the two types of nonlinear differential equation problems in engineering dynamics, the author proposes a numerical analysis method for the two types of nonlinear differential equations based on computer simulation. This method establishes the MATLAB algorithm structure of the numerical solution of the fourth-order fixed-step Runge-Kutta and Lorenz models, discusses the error control in the case of variable step size, and plots the numerical solutions of the Lorenz system based on MATLAB in two-dimensional and three-dimensional space graphics. Thex-direction displacement and y-direction displacement data are extracted from the Lorenz equation as iterative samples of the model, the regression curve obtained after iteration has a slope of 0.996, and the iterative regression model reflects the basic characteristics of the data well. This method presents the basic idea of numerical solution verification within acceptable error limits. For solving engineering problems with differential equations as mathematical models, an effective numerical solution method is provided, and further discussion on the numerical solutions of partial differential equations is of great significance.


---

## Body

## 1. Introduction

We know that the dynamic changes of many systems in the real world can be expressed by differential equations; in order to study the evolution law of the system, the solution of differential equations has become a very important problem. The theory and method of differential equations have always been one of the keys to the development of modern science and technology and also one of the key issues of mathematical research. However, most differential equations cannot be solved analytically, and even some differential equations that can be solved require very high skills; differential equations are a compilation of tricks [1]. Therefore, while people are looking for analytic solutions, discussing and studying the analytical features of the solutions have also become one of people’s research methods. Especially with the rapid development of nonlinear scientific research, people not only need to discuss individual solutions of differential equations but also try to know the general trend and structure of a large class of solutions or all solutions; it is not only satisfied with the discussion of the local properties of the solution but also cares about the topological structure of the orbital formed by a solution in the corresponding space and even cares whether this structure will be destroyed due to small perturbations, in the case of perturbation and no perturbation, whether there will be orbital structures that are different from each other. People hope to study differential equations from a higher perspective, with newer viewpoints, and with more advanced methods, so as to obtain more and more profound results, which leads to the rise of the research upsurge of differential dynamical systems [2]. To put it simply, what the differential dynamic system pursues is to analyze the differential equations from the perspective of topology, so as to reveal the essential laws of the change and development of things.The world we live in and face is an evolutionary system that is extremely complex. Complexity is everywhere, and complex systems are everywhere, such as cosmic celestial bodies, biological systems, and social systems. Currently, there is no unified understanding of complexity. It is generally believed that complexity can be summed up as the multilevel, multifactor, and multivariability of the system, the interaction between various factors or subsystems and between the system and the environment, and the ensuing overall behavior and evolution [3]. The so-called complexity research is to study the composition, structure, function, and interaction of the system, study the overall behavior and evolution of the system and the mechanisms that control them, and then establish models, conduct simulation experiments, and further influence, manage, and control them.


## 2. Literature Review

For this research question, Tu et al. based on the probability representation of linear backward stochastic differential equations proposed an approximate solution method for linear partial differential equations [4]. Leonov proposed an approximate solution to nonlinear parabolic partial differential equations based on second-order backward stochastic differential equations [5]. Zhu gave a numerical algorithm based on the probabilistic representation of the branch-diffusion process, which exploits the fact that the solutions of semilinear PDEs with a polynomial nonlinear form can be expressed as the expectation of the branch-diffusion process functional; although this method does not have the curse of dimensionality problem, its applicability is still limited due to the instability of the approximate solution in finite time [6]. For the high-dimensional case of such equations, Nafil et al. developed an algorithm based on compressed sensing and the Hopf formulation of the Hamilton-Jacobi equation, which achieved good numerical performance in high-dimensional cases [7]. Abdulwahid et al. proposed a general algorithm for this type of equation based on the Feynman-Kac formula, Bismut-Elworthy-Li formula, and Picard iterative multilevel decomposition, which has been proven for some applications in finance and physics very effective. For semilinear parabolic PDEs, the computational complexity of the algorithm is Odε−4, where d is the dimension of the equation and ε is the desired precision [8]. Baothman and Edhah exploited recent advances in probabilistic machine learning to infer governing equations represented by parametric linear operators [9]. This method modifies the Gaussian process prior according to the form of the equation and is used to infer the parameters of linear PDEs from observations. Liu et al. proposed the use of deep neural networks to approximate the solutions of high-dimensional partial differential equations; the network is iterated to satisfy differential operators, initial conditions, and boundary conditions; the neural network operates on a randomly sampled set of time and space points, iteratively; the solution is approximated by a neural network [10]. Parise et al. by using different neural network structures and different parameterizations improved machine learning algorithms for solving semilinear partial differential equations; the proposed algorithm is compared with several algorithms that utilize deep learning techniques to solve semilinear PDE problems [11]. Ly et al. reviewed methods for solving partial differential equations using physics-informed neural networks (PINNs), a novel residual-based adaptive optimization method proposed to improve the iterative efficiency of PINNs. This paper also provides a Python program library DeepXDE for the implementation of PINNs; the program library DeepXDE can solve the forward problem of given initial value conditions and boundary value conditions and can also solve the inverse problem given additional measurement results [12].“Numerical analysis” is the main content of computational mathematics, and its research scope covers almost all branches of mathematical science; in turn, many branches of mathematics need to explore numerical methods applicable to computers. In the theory of numerical calculation, the analytical solution of the general nonlinear differential equation does not exist and can only be solved numerically. The numerical solution problem and algorithm realization of nonlinear differential equations have very important applications in engineering dynamic control, computer simulation, mathematical modeling, etc. Figure1 shows the nonlinear simulation technology. The author will study the algorithm, error, step size, and other problems of numerical solution of general nonlinear differential equation problems, the fourth-order fixed step size Runge-Kutta and its improved algorithm, and the numerical solution of the Lorenz model, which is the graphical interface for the results of MATLAB real variable operations.Figure 1
Nonlinear simulation technology.


## 3. Research Methods

### 3.1. Overview of Algorithms for Differential Equation Problems

As an important branch of mathematics, nonlinear differential equations and equation systems are traditional mathematical tools to describe or solve nonlinear dynamical system problems and have been widely used in many fields [13].The numerical solutions of general differential equations are mostly numerical solutions to the initial value problems of differential equations; such problems can be described as the following formula (1) with a first-order explicit differential equation system:
(1)ẋt=ft,xt.Among them,xTt=x1t,x2t,⋯,xnt is called the state vector, and fT·=f1·,f2·,⋯,fn· can be any nonlinear function.In the initial value problem, if the initial statex0=x10,⋯,xn0T is known, the numerical solution method is used to obtain the value of each variable state xt in a certain interval t∈0,tf; tf is also called the terminal variable [14].


### 3.2. Numerical Algorithm of Multivariate Nonlinear Differential Equations and Problems of Error and Step Size

#### 3.2.1. Numerical Algorithm for Initial Value Problem

The multivariate nonlinear extremum problem is a very common mathematical problem; in theory, the multivariate nonlinear extremum problem is often reduced to the root-finding problem of the multivariate nonlinear equation system, and then, the Newton iteration method is used to calculate it. But in fact, the root-finding problem of multivariate nonlinear equations is more difficult to solve than the extremum problem of multivariate nonlinear functions. In computational mathematics, in order to solve the multivariate extreme value problem, many new methods have been introduced, such as the steepest descent method, genetic algorithm, and edge detection algorithm [15].For the initial value problem of multivariate nonlinear differential equations, Euler’s algorithm is a class that is easier to understand and control than other algorithms and is widely used in the numerical solution of complex differential equations; the following will give a numerical algorithm for the initial value problem of nonlinear differential equations based on MATLAB, taking Euler’s algorithm as an example.Assuming that the value of the system state vector at timet0 is known to be xt0, if a smaller calculation step h is selected, the derivative on the left side of the differential equation can be approximated as xt0+h−xt0/t0+h−t0, and the approximate solution of the equation at time t0+h can be obtained by substituting it into the differential equation in the following:
(2)x^t0+h=xt0=hft0,xt0.Due to the existence of the approximate solution error, the value of the system state vector at timet0+h can be strictly expressed as the following:
(3)xt0+h=xt0+hft,xt0+R0.Or denoted asx1=xt0+h, then x^1=x^t0+h is the approximate value of the system state vector at t0+h time, that is, the numerical solution, where R0 is the rounding error of the numerical solution.More generally, assuming that the state vector of the system at timetk is xk, the numerical solution of Euler’s algorithm at time xk+h can be written as
(4)xk+1=xk+hft,xk.For the above general numerical solution expression, the iterative method can be used to gradually obtain the given initial value problem within a certain time periodt∈0,T, the original numerical solution at each time instant t0+khk=1,2,∙∙∙,n [16].


#### 3.2.2. Accuracy Control of Numerical Solution and Analysis of Influencing Factors of Variable Step Size

For the effect of variable step size on accuracy and speed, an effective way to improve the accuracy of numerical solutions is to reduce the value of the step sizeh, but the continuous decrease of the step size value will cause the following two problems:Reduce operation speed. For the chosen solution time limit, reducing the step size is equivalent to increasing the number of computational points in a fixed time interval, which directly leads to a sharp drop in computational speed [17].Expand the cumulative error. Due to the inherent error of the numerical solution, even if a small step size is chosen, the obtained numerical solution will be accompanied by a rounding error; decreasing the step size increases the number of loops, which increases the number of passes for the rounding error stacking, resulting in a larger cumulative error.A schematic diagram of the relationship between rounding error, accumulated error, and total error is shown in Figure2.Figure 2
Error diagram.For an effective way of error control, in multivariate nonlinear differential equations, step size and error are a pair of contradictions; according to the algorithm and accuracy requirements of the actual problem, the following ways can be used to choose:Choose an appropriate step size. When using a simple algorithm like Euler, the step size should be moderate and follow the principle of rather small rather than large.Improve the accuracy of the approximation algorithm. Since the Euler algorithm only converts the original integral problem into a trapezoidal method for the approximate solution, it cannot effectively approximate the original problem due to its low accuracy.The composite Simpson method or the more accurate spline interpolation method can be used to replace the Euler algorithm, among which the Runge-Kutta method and the Adams method are the most common [18, 19].In using the variable step size method, in the numerical solution of multivariate differential equations, many methods can be solved by variable step size; if the error is small, the step size will be increased, and if the error is large, the step size will be automatically reduced, so as to solve the initial value problem of differential equations accurately and effectively.The principle of the general variable step size algorithm is shown in Figure3. Knowing the state variable xk at time tk, calculate the state variable x^k+1 under the step size h and h/2, respectively; if the error ε=x^k+1−x~k+1 under the two step sizes is less than the given error limit, the step size can be used. If the error is large, gradually reduce the step size until the error is reduced to the allowable range [20]. This adaptive variable step size algorithm can solve two problems at the same time, namely, operation speed and calculation accuracy.Figure 3
Schematic diagram of variable step size.


### 3.3. Algorithms and Functions for Numerical Solutions of Two Types of First-Order Differential Equations

The key to solving a system of first-order explicit differential equations is to write a function in MATLAB language and describe the system of differential equations to be solved.In nonlinear differential equation solving, it is sometimes necessary to further set the algorithm and control conditions, which can be modified by the options variable in the solving process, and the initial variable can be obtained by the odeset() function.For practical applications, it is often necessary to define some additional parameters, which can be represented bym1,m2,∙∙∙,mn. The following two types of important algorithms in numerical analysis will be analyzed, and a general program structure will be established.


#### 3.3.1. Fourth-Order Fixed-Step Runge-Kutta Algorithm and Its Improvement

For a complex function, it is always prohibitive to use Taylor expansion to find its derivatives; Runge-Kutta uses the idea of the Taylor series method but avoids the analytical derivation of the original function process. Therefore, in essence, Runge-Kutta is based on the Taylor series method; it abandons the drawbacks of the Taylor series method for derivatives and uses the idea of compound functions to achieve derivatives [21]. The Runge-Kutta method is a high-precision single-step algorithm widely used in engineering, including the well-known Euler method, which numerically solves differential equations. Due to the high precision of this algorithm, measures are taken to suppress the error. The numerical solution is obtained by the fourth-order Runge-Kutta method; its accuracy may not be as good as the improved Euler method. In the actual calculation, the appropriate algorithm should be selected according to the specific characteristics of the problem. For solutions with poor smoothness, it is better to use a low-order algorithm with a small step size.The fourth-order fixed-step Runge-Kutta algorithm is an important algorithm in numerical analysis and system simulation theory. Its mathematical algorithm needs to define 4 additional vectors first, as shown in the following:(5)k1=hftk,xk,k2=hftk+h2,xk+k12,k3=hftk+h2,xk+k22,k4=hftk+h,xk+k3.Among them, Simpson is the calculation step, which is a constant in practical applications, and then, the state variable value of the next step is calculated by the Runge-Kutta algorithm as the following:(6)xk+1=xk+16k1+2k2+2k3+k4.For the above expression, the iterative method is used to obtain the numerical solution at each time pointt0+h,t0+2h,⋯ [22].Based on mathematical algorithms, in MATLAB, the solution can be achieved through a set of loop statements.In the above MATLAB algorithm, the variable span has two construction methods, namely, the equidistant time vector and the variable step vector based ont0, tf, h. After the function call ends, the matrix formed by the time vector and the state variable is returned by tout and yout in the program, respectively.The abovementioned algorithm is characterized by simple structure and fast operation speed, but its limitation lies in its low precision. In order to ensure higher accuracy and numerical stability, we improve the above algorithm in terms of step size increment: that is, thefi∙ function is evaluated 6 times in each calculation step, and this algorithm is called the fourth-order five-level RKF algorithm [23].For the current step sizehk, six variables can be defined as follows:
(7)ki=hkftk+αihk,xk+∑j=1i−1βijkji=1,2,⋯,6.In the formula,xk+1=xk+∑i=16γiki is the current calculation time, and the intermediate parameters αi and βij can be given by the RKF algorithm coefficient table. At this time, the state vector can be expressed as the following:
(8)xk+1=xk+∑i=16γiki.In the above algorithm, if an error vectorεk=∑i=16γi−γi∗ki is defined, the step size can be changed by the size of εk, thereby transforming into an adaptive variable step size algorithm, which makes the whole program easier to control [24].


#### 3.3.2. Numerical Algorithm of Lorenz Model

The Lorenz model is a well-known equation describing chaotic phenomena, and the Lorenz system is worthy of detailed study from the point of view of both mathematics and physics [25].Suppose the state equation of the Lorenz model is the following:(9)ẋ1t=−βx1t+x2tx3t,ẋ2t=−ρx2t+ρx3t,ẋ3t=−x1tx2t+σx2t−x3t.Among them,β, ρ, σ are fixed values, x10=x20=0,x30=ε is the initial value, and for ε=10−10, the numerical solution of the system of equations is obtained.Since this equation is a nonlinear differential equation and there is no analytical solution, we can complete the programming of the numerical algorithm based on MATLAB according to the following steps.First, use the Lorenzep.m function to describe the dynamic model of the system.Then, call the numerical solution function ode45() to numerically solve the system described by the Lorenzep() function, and display the result graphically.Among them, t_final is the set simulation termination time, x0 is the initial state, and the two commands draw the two-dimensional curve graph of the time relationship of each state of the system (as shown in Figures4–6) and the phase of the three state space graphs.Figure 4
Phase space plot of thex state.Figure 5
Phase space plot ofy state.Figure 6
Phase space plot ofz state.In the above program, the comet3() function can also be used to draw an animated trajectory for observing the phase space trajectory; just rewrite the last statement appropriately. In order to establish a description function based on the MATLAB differential equation system, ode45() must be called, so writing the MATLAB function to describe the differential equation is the key to the numerical solution of the initial value problem, especially for the first-order nonlinear differential equation.


## 3.1. Overview of Algorithms for Differential Equation Problems

As an important branch of mathematics, nonlinear differential equations and equation systems are traditional mathematical tools to describe or solve nonlinear dynamical system problems and have been widely used in many fields [13].The numerical solutions of general differential equations are mostly numerical solutions to the initial value problems of differential equations; such problems can be described as the following formula (1) with a first-order explicit differential equation system:
(1)ẋt=ft,xt.Among them,xTt=x1t,x2t,⋯,xnt is called the state vector, and fT·=f1·,f2·,⋯,fn· can be any nonlinear function.In the initial value problem, if the initial statex0=x10,⋯,xn0T is known, the numerical solution method is used to obtain the value of each variable state xt in a certain interval t∈0,tf; tf is also called the terminal variable [14].


## 3.2. Numerical Algorithm of Multivariate Nonlinear Differential Equations and Problems of Error and Step Size

### 3.2.1. Numerical Algorithm for Initial Value Problem

The multivariate nonlinear extremum problem is a very common mathematical problem; in theory, the multivariate nonlinear extremum problem is often reduced to the root-finding problem of the multivariate nonlinear equation system, and then, the Newton iteration method is used to calculate it. But in fact, the root-finding problem of multivariate nonlinear equations is more difficult to solve than the extremum problem of multivariate nonlinear functions. In computational mathematics, in order to solve the multivariate extreme value problem, many new methods have been introduced, such as the steepest descent method, genetic algorithm, and edge detection algorithm [15].For the initial value problem of multivariate nonlinear differential equations, Euler’s algorithm is a class that is easier to understand and control than other algorithms and is widely used in the numerical solution of complex differential equations; the following will give a numerical algorithm for the initial value problem of nonlinear differential equations based on MATLAB, taking Euler’s algorithm as an example.Assuming that the value of the system state vector at timet0 is known to be xt0, if a smaller calculation step h is selected, the derivative on the left side of the differential equation can be approximated as xt0+h−xt0/t0+h−t0, and the approximate solution of the equation at time t0+h can be obtained by substituting it into the differential equation in the following:
(2)x^t0+h=xt0=hft0,xt0.Due to the existence of the approximate solution error, the value of the system state vector at timet0+h can be strictly expressed as the following:
(3)xt0+h=xt0+hft,xt0+R0.Or denoted asx1=xt0+h, then x^1=x^t0+h is the approximate value of the system state vector at t0+h time, that is, the numerical solution, where R0 is the rounding error of the numerical solution.More generally, assuming that the state vector of the system at timetk is xk, the numerical solution of Euler’s algorithm at time xk+h can be written as
(4)xk+1=xk+hft,xk.For the above general numerical solution expression, the iterative method can be used to gradually obtain the given initial value problem within a certain time periodt∈0,T, the original numerical solution at each time instant t0+khk=1,2,∙∙∙,n [16].


### 3.2.2. Accuracy Control of Numerical Solution and Analysis of Influencing Factors of Variable Step Size

For the effect of variable step size on accuracy and speed, an effective way to improve the accuracy of numerical solutions is to reduce the value of the step sizeh, but the continuous decrease of the step size value will cause the following two problems:Reduce operation speed. For the chosen solution time limit, reducing the step size is equivalent to increasing the number of computational points in a fixed time interval, which directly leads to a sharp drop in computational speed [17].Expand the cumulative error. Due to the inherent error of the numerical solution, even if a small step size is chosen, the obtained numerical solution will be accompanied by a rounding error; decreasing the step size increases the number of loops, which increases the number of passes for the rounding error stacking, resulting in a larger cumulative error.A schematic diagram of the relationship between rounding error, accumulated error, and total error is shown in Figure2.Figure 2
Error diagram.For an effective way of error control, in multivariate nonlinear differential equations, step size and error are a pair of contradictions; according to the algorithm and accuracy requirements of the actual problem, the following ways can be used to choose:Choose an appropriate step size. When using a simple algorithm like Euler, the step size should be moderate and follow the principle of rather small rather than large.Improve the accuracy of the approximation algorithm. Since the Euler algorithm only converts the original integral problem into a trapezoidal method for the approximate solution, it cannot effectively approximate the original problem due to its low accuracy.The composite Simpson method or the more accurate spline interpolation method can be used to replace the Euler algorithm, among which the Runge-Kutta method and the Adams method are the most common [18, 19].In using the variable step size method, in the numerical solution of multivariate differential equations, many methods can be solved by variable step size; if the error is small, the step size will be increased, and if the error is large, the step size will be automatically reduced, so as to solve the initial value problem of differential equations accurately and effectively.The principle of the general variable step size algorithm is shown in Figure3. Knowing the state variable xk at time tk, calculate the state variable x^k+1 under the step size h and h/2, respectively; if the error ε=x^k+1−x~k+1 under the two step sizes is less than the given error limit, the step size can be used. If the error is large, gradually reduce the step size until the error is reduced to the allowable range [20]. This adaptive variable step size algorithm can solve two problems at the same time, namely, operation speed and calculation accuracy.Figure 3
Schematic diagram of variable step size.


## 3.2.1. Numerical Algorithm for Initial Value Problem

The multivariate nonlinear extremum problem is a very common mathematical problem; in theory, the multivariate nonlinear extremum problem is often reduced to the root-finding problem of the multivariate nonlinear equation system, and then, the Newton iteration method is used to calculate it. But in fact, the root-finding problem of multivariate nonlinear equations is more difficult to solve than the extremum problem of multivariate nonlinear functions. In computational mathematics, in order to solve the multivariate extreme value problem, many new methods have been introduced, such as the steepest descent method, genetic algorithm, and edge detection algorithm [15].For the initial value problem of multivariate nonlinear differential equations, Euler’s algorithm is a class that is easier to understand and control than other algorithms and is widely used in the numerical solution of complex differential equations; the following will give a numerical algorithm for the initial value problem of nonlinear differential equations based on MATLAB, taking Euler’s algorithm as an example.Assuming that the value of the system state vector at timet0 is known to be xt0, if a smaller calculation step h is selected, the derivative on the left side of the differential equation can be approximated as xt0+h−xt0/t0+h−t0, and the approximate solution of the equation at time t0+h can be obtained by substituting it into the differential equation in the following:
(2)x^t0+h=xt0=hft0,xt0.Due to the existence of the approximate solution error, the value of the system state vector at timet0+h can be strictly expressed as the following:
(3)xt0+h=xt0+hft,xt0+R0.Or denoted asx1=xt0+h, then x^1=x^t0+h is the approximate value of the system state vector at t0+h time, that is, the numerical solution, where R0 is the rounding error of the numerical solution.More generally, assuming that the state vector of the system at timetk is xk, the numerical solution of Euler’s algorithm at time xk+h can be written as
(4)xk+1=xk+hft,xk.For the above general numerical solution expression, the iterative method can be used to gradually obtain the given initial value problem within a certain time periodt∈0,T, the original numerical solution at each time instant t0+khk=1,2,∙∙∙,n [16].


## 3.2.2. Accuracy Control of Numerical Solution and Analysis of Influencing Factors of Variable Step Size

For the effect of variable step size on accuracy and speed, an effective way to improve the accuracy of numerical solutions is to reduce the value of the step sizeh, but the continuous decrease of the step size value will cause the following two problems:Reduce operation speed. For the chosen solution time limit, reducing the step size is equivalent to increasing the number of computational points in a fixed time interval, which directly leads to a sharp drop in computational speed [17].Expand the cumulative error. Due to the inherent error of the numerical solution, even if a small step size is chosen, the obtained numerical solution will be accompanied by a rounding error; decreasing the step size increases the number of loops, which increases the number of passes for the rounding error stacking, resulting in a larger cumulative error.A schematic diagram of the relationship between rounding error, accumulated error, and total error is shown in Figure2.Figure 2
Error diagram.For an effective way of error control, in multivariate nonlinear differential equations, step size and error are a pair of contradictions; according to the algorithm and accuracy requirements of the actual problem, the following ways can be used to choose:Choose an appropriate step size. When using a simple algorithm like Euler, the step size should be moderate and follow the principle of rather small rather than large.Improve the accuracy of the approximation algorithm. Since the Euler algorithm only converts the original integral problem into a trapezoidal method for the approximate solution, it cannot effectively approximate the original problem due to its low accuracy.The composite Simpson method or the more accurate spline interpolation method can be used to replace the Euler algorithm, among which the Runge-Kutta method and the Adams method are the most common [18, 19].In using the variable step size method, in the numerical solution of multivariate differential equations, many methods can be solved by variable step size; if the error is small, the step size will be increased, and if the error is large, the step size will be automatically reduced, so as to solve the initial value problem of differential equations accurately and effectively.The principle of the general variable step size algorithm is shown in Figure3. Knowing the state variable xk at time tk, calculate the state variable x^k+1 under the step size h and h/2, respectively; if the error ε=x^k+1−x~k+1 under the two step sizes is less than the given error limit, the step size can be used. If the error is large, gradually reduce the step size until the error is reduced to the allowable range [20]. This adaptive variable step size algorithm can solve two problems at the same time, namely, operation speed and calculation accuracy.Figure 3
Schematic diagram of variable step size.


## 3.3. Algorithms and Functions for Numerical Solutions of Two Types of First-Order Differential Equations

The key to solving a system of first-order explicit differential equations is to write a function in MATLAB language and describe the system of differential equations to be solved.In nonlinear differential equation solving, it is sometimes necessary to further set the algorithm and control conditions, which can be modified by the options variable in the solving process, and the initial variable can be obtained by the odeset() function.For practical applications, it is often necessary to define some additional parameters, which can be represented bym1,m2,∙∙∙,mn. The following two types of important algorithms in numerical analysis will be analyzed, and a general program structure will be established.


### 3.3.1. Fourth-Order Fixed-Step Runge-Kutta Algorithm and Its Improvement

For a complex function, it is always prohibitive to use Taylor expansion to find its derivatives; Runge-Kutta uses the idea of the Taylor series method but avoids the analytical derivation of the original function process. Therefore, in essence, Runge-Kutta is based on the Taylor series method; it abandons the drawbacks of the Taylor series method for derivatives and uses the idea of compound functions to achieve derivatives [21]. The Runge-Kutta method is a high-precision single-step algorithm widely used in engineering, including the well-known Euler method, which numerically solves differential equations. Due to the high precision of this algorithm, measures are taken to suppress the error. The numerical solution is obtained by the fourth-order Runge-Kutta method; its accuracy may not be as good as the improved Euler method. In the actual calculation, the appropriate algorithm should be selected according to the specific characteristics of the problem. For solutions with poor smoothness, it is better to use a low-order algorithm with a small step size.The fourth-order fixed-step Runge-Kutta algorithm is an important algorithm in numerical analysis and system simulation theory. Its mathematical algorithm needs to define 4 additional vectors first, as shown in the following:(5)k1=hftk,xk,k2=hftk+h2,xk+k12,k3=hftk+h2,xk+k22,k4=hftk+h,xk+k3.Among them, Simpson is the calculation step, which is a constant in practical applications, and then, the state variable value of the next step is calculated by the Runge-Kutta algorithm as the following:(6)xk+1=xk+16k1+2k2+2k3+k4.For the above expression, the iterative method is used to obtain the numerical solution at each time pointt0+h,t0+2h,⋯ [22].Based on mathematical algorithms, in MATLAB, the solution can be achieved through a set of loop statements.In the above MATLAB algorithm, the variable span has two construction methods, namely, the equidistant time vector and the variable step vector based ont0, tf, h. After the function call ends, the matrix formed by the time vector and the state variable is returned by tout and yout in the program, respectively.The abovementioned algorithm is characterized by simple structure and fast operation speed, but its limitation lies in its low precision. In order to ensure higher accuracy and numerical stability, we improve the above algorithm in terms of step size increment: that is, thefi∙ function is evaluated 6 times in each calculation step, and this algorithm is called the fourth-order five-level RKF algorithm [23].For the current step sizehk, six variables can be defined as follows:
(7)ki=hkftk+αihk,xk+∑j=1i−1βijkji=1,2,⋯,6.In the formula,xk+1=xk+∑i=16γiki is the current calculation time, and the intermediate parameters αi and βij can be given by the RKF algorithm coefficient table. At this time, the state vector can be expressed as the following:
(8)xk+1=xk+∑i=16γiki.In the above algorithm, if an error vectorεk=∑i=16γi−γi∗ki is defined, the step size can be changed by the size of εk, thereby transforming into an adaptive variable step size algorithm, which makes the whole program easier to control [24].


### 3.3.2. Numerical Algorithm of Lorenz Model

The Lorenz model is a well-known equation describing chaotic phenomena, and the Lorenz system is worthy of detailed study from the point of view of both mathematics and physics [25].Suppose the state equation of the Lorenz model is the following:(9)ẋ1t=−βx1t+x2tx3t,ẋ2t=−ρx2t+ρx3t,ẋ3t=−x1tx2t+σx2t−x3t.Among them,β, ρ, σ are fixed values, x10=x20=0,x30=ε is the initial value, and for ε=10−10, the numerical solution of the system of equations is obtained.Since this equation is a nonlinear differential equation and there is no analytical solution, we can complete the programming of the numerical algorithm based on MATLAB according to the following steps.First, use the Lorenzep.m function to describe the dynamic model of the system.Then, call the numerical solution function ode45() to numerically solve the system described by the Lorenzep() function, and display the result graphically.Among them, t_final is the set simulation termination time, x0 is the initial state, and the two commands draw the two-dimensional curve graph of the time relationship of each state of the system (as shown in Figures4–6) and the phase of the three state space graphs.Figure 4
Phase space plot of thex state.Figure 5
Phase space plot ofy state.Figure 6
Phase space plot ofz state.In the above program, the comet3() function can also be used to draw an animated trajectory for observing the phase space trajectory; just rewrite the last statement appropriately. In order to establish a description function based on the MATLAB differential equation system, ode45() must be called, so writing the MATLAB function to describe the differential equation is the key to the numerical solution of the initial value problem, especially for the first-order nonlinear differential equation.


## 3.3.1. Fourth-Order Fixed-Step Runge-Kutta Algorithm and Its Improvement

For a complex function, it is always prohibitive to use Taylor expansion to find its derivatives; Runge-Kutta uses the idea of the Taylor series method but avoids the analytical derivation of the original function process. Therefore, in essence, Runge-Kutta is based on the Taylor series method; it abandons the drawbacks of the Taylor series method for derivatives and uses the idea of compound functions to achieve derivatives [21]. The Runge-Kutta method is a high-precision single-step algorithm widely used in engineering, including the well-known Euler method, which numerically solves differential equations. Due to the high precision of this algorithm, measures are taken to suppress the error. The numerical solution is obtained by the fourth-order Runge-Kutta method; its accuracy may not be as good as the improved Euler method. In the actual calculation, the appropriate algorithm should be selected according to the specific characteristics of the problem. For solutions with poor smoothness, it is better to use a low-order algorithm with a small step size.The fourth-order fixed-step Runge-Kutta algorithm is an important algorithm in numerical analysis and system simulation theory. Its mathematical algorithm needs to define 4 additional vectors first, as shown in the following:(5)k1=hftk,xk,k2=hftk+h2,xk+k12,k3=hftk+h2,xk+k22,k4=hftk+h,xk+k3.Among them, Simpson is the calculation step, which is a constant in practical applications, and then, the state variable value of the next step is calculated by the Runge-Kutta algorithm as the following:(6)xk+1=xk+16k1+2k2+2k3+k4.For the above expression, the iterative method is used to obtain the numerical solution at each time pointt0+h,t0+2h,⋯ [22].Based on mathematical algorithms, in MATLAB, the solution can be achieved through a set of loop statements.In the above MATLAB algorithm, the variable span has two construction methods, namely, the equidistant time vector and the variable step vector based ont0, tf, h. After the function call ends, the matrix formed by the time vector and the state variable is returned by tout and yout in the program, respectively.The abovementioned algorithm is characterized by simple structure and fast operation speed, but its limitation lies in its low precision. In order to ensure higher accuracy and numerical stability, we improve the above algorithm in terms of step size increment: that is, thefi∙ function is evaluated 6 times in each calculation step, and this algorithm is called the fourth-order five-level RKF algorithm [23].For the current step sizehk, six variables can be defined as follows:
(7)ki=hkftk+αihk,xk+∑j=1i−1βijkji=1,2,⋯,6.In the formula,xk+1=xk+∑i=16γiki is the current calculation time, and the intermediate parameters αi and βij can be given by the RKF algorithm coefficient table. At this time, the state vector can be expressed as the following:
(8)xk+1=xk+∑i=16γiki.In the above algorithm, if an error vectorεk=∑i=16γi−γi∗ki is defined, the step size can be changed by the size of εk, thereby transforming into an adaptive variable step size algorithm, which makes the whole program easier to control [24].


## 3.3.2. Numerical Algorithm of Lorenz Model

The Lorenz model is a well-known equation describing chaotic phenomena, and the Lorenz system is worthy of detailed study from the point of view of both mathematics and physics [25].Suppose the state equation of the Lorenz model is the following:(9)ẋ1t=−βx1t+x2tx3t,ẋ2t=−ρx2t+ρx3t,ẋ3t=−x1tx2t+σx2t−x3t.Among them,β, ρ, σ are fixed values, x10=x20=0,x30=ε is the initial value, and for ε=10−10, the numerical solution of the system of equations is obtained.Since this equation is a nonlinear differential equation and there is no analytical solution, we can complete the programming of the numerical algorithm based on MATLAB according to the following steps.First, use the Lorenzep.m function to describe the dynamic model of the system.Then, call the numerical solution function ode45() to numerically solve the system described by the Lorenzep() function, and display the result graphically.Among them, t_final is the set simulation termination time, x0 is the initial state, and the two commands draw the two-dimensional curve graph of the time relationship of each state of the system (as shown in Figures4–6) and the phase of the three state space graphs.Figure 4
Phase space plot of thex state.Figure 5
Phase space plot ofy state.Figure 6
Phase space plot ofz state.In the above program, the comet3() function can also be used to draw an animated trajectory for observing the phase space trajectory; just rewrite the last statement appropriately. In order to establish a description function based on the MATLAB differential equation system, ode45() must be called, so writing the MATLAB function to describe the differential equation is the key to the numerical solution of the initial value problem, especially for the first-order nonlinear differential equation.


## 4. Result Analysis

In the process of numerical solution, if the simulation algorithm and control parameters are not selected properly, unreliable results or even wrong results may be obtained; therefore, the verification of the numerical solution can be carried out in two ways. A feasible method is to modify the simulation control parameters, such as the acceptable error limit, such as setting the RelTol option to a smaller value, and observe the obtained results to see if they are consistent with the results of the first run; if there are no unacceptable differences, further reductions in the error limits should be considered. In addition, choosing a differential equation solving algorithm for the same problem can also check the correctness of the operation result.Thex-direction displacement and y-direction displacement data are extracted from the Lorenz equation as an iterative sample of the model, and the iterative results are shown in Figure 7. The dots in Figure 7 represent the extracted sample points, and the straight line represents the regression curve obtained after the iteration of the sample data, with a slope of 0.996; the iterative regression model reflects the basic characteristics of the data well.Figure 7
Lorenz equationx,y data image regression curve.


## 5. Conclusion

The solution and simulation of scientific or engineering problems often boil down to the solution of mathematical models and the fitting of experimental data, while nonlinear differential equations, as an important mathematical terminal model, can only be solved numerically. Through the systematic analysis of the fourth-order fixed-step Runge-Kutta algorithm and the Lorenz model algorithm, the author established a variable-step adaptive algorithm based on nonlinear differential equations and the MATLAB program structure under the explicit function description; the key elements such as step size, error, and numerical solution verification are analyzed; and the influencing factors are analyzed, and relevant conclusions are drawn. It provides an effective numerical solution method for solving engineering problems with differential equations as mathematical models, and further discussion on the numerical solutions of partial differential equations is also of great significance.



---

*Source: 9181840-2022-07-29.xml*