Mathematical Modeling of Real-Time Systems Using Heun and Piecewise Methods

It is often said that mathematical modeling is an implementation of mathematics in real-world problems with the aim of better understanding them, so we can say that mathematical modeling is linked to the solution of problems. Some of the essential principles and procedures of mathematical modeling are discussed using formulas and equations. We investigate the stability and convergence characteristics and demonstrate the suitability of dierent mathematical methods in a set of numerical examples.e described methods in our paper are the best choices for the simulation of linear phenomena and are more ecient for use with high-order spatial discretization. We emphasized the importance of mathematical modeling technologies used in computational tools. Our study shows that these new methods are more stable with lower errors.


Introduction
Various numerical methods are used to obtain the initial value solution, and studies show great development on this topic in this century. Other factors also amount to the reason for the implementation of mathematical methods like electronic computers needing e cient numerical algorithms in mathematical modeling. Many complex methods that are driven by partial di erential equations (PDE) evolve [1][2][3], which requires the search for the appropriate numerical solution to a system of ordinary di erential equations (ODEs) in a wide range of situations [4][5][6]. e di erential equations contain derivatives, either ordinary or partial derivatives, and along with an initial condition that determines the value of the unknown function at a certain point, make up the initial value problem (IVP). ese equations are also used in semiconductor engineering, biology, chemistry, physics, and economics to solve various problems in research.
ere are several analytical approaches for determining the solution of di erential equations [7,8]. On the other hand, analytical methods cannot always solve complex di erential equations. erefore, it is important to make numerical approximations. e advanced di erential equation is solved by using numerical techniques for which computer programming is a very powerful tool. e well-known Runge-Kutta (RK) analysis is the most often used technique for integrating these technologies of ODEs in real time [7][8][9][10]. RK methods can be classi ed in a variety of ways, such as the structure of implicit or explicit, by convergence order, or the number of steps [1]. e complexity of the equation that must be solved determines the numerical stability of various numerical methods. Figure 1 summarizes the ow of ordinary equations used to model real-time systems and the application of analytical and numerical methods to solve these equations. An example here is encapsulating the physical characteristics of a parachutist descending, where g is gravitational constant, m is mass, c is drag coe cient, and dv/dt is an unknown function/di erential equation (rate equation).
In the RK family, the most well-known member is the classic Runge-Kutta method (RK4), and (1) presents the initial problem as follows: In the above equation (1), y can be a scalar or vector function that is not known at time t that we want to estimate. dy/dt is the time rate at which y changes and t 0 is the initial time; hence, the corresponding y value is y 0 .
e k 1 and k 2 are known as stages of the RK method which are shown in (2) and (3). ey relate to various estimations of solutions for the slope. We note here that y n + hk 1 is the Euler step from (t n , y n ) with stepsize h. Now, the following equation shows an explicit second-order RK method by supposing erefore, the second-order RK supposition becomes erefore, for four unknowns, we have three nonlinear equations which lead to Euler's method ( rst-order method). Euler's method is commonly used to build more complicated approaches like the predictor/corrector method and is sometimes also called the midpoint rule as follows: y n+1 y n + hk 2 , k 1 f t n , y n , As we know, the RK methods are a set of implicit and explicit optimization methods in numerical analysis, including the well-known Euler's method, which is usually used in temporal discretization for approximate solutions of ODEs [1,11]. Here, the di erential equation is considered as a formula that can be used to compute the slope of the tangent line to the curve at any point once we determined the location of that point. e solution to the ODE at a time t n : y n ≈ y(t n ) is approximated by the value of y n . e explicit Euler's method shows that the solution y n+1 is an explicit function of y i for i ≤ n. We must mention here that there is no assurance about any curves' concavity that will Numerical Figure 1: e summary of steps in the application of ODEs to engineering problem solving, such as a parachutist descending.
remain consistent. It may shift from concave-up to concavedown. Because the real solution curve goes up and down, there is no approximate way to estimate whether our next point will be an over-or underestimate. To overcome this deficiency, we have a clever Heun's method to use.

Heun's Method
Heun's method is the improved (or modified) Euler method and the second order of the RK method. e modified Euler method allows us to find a clear expression for y given a finite number of elementary functions, x. It is possible to solve the ODE for y and x given their initial values. e Euler's method algorithm is as follows: (1) Start (2) Define function (3) Determine x0, y0, h, and xn (here x0 and y0 are initial conditions while h is interval and xn is required value) If no, go to 9 (9) Loop i end (10) Stop We can use the algorithm and flowchart in a high-level programming language to construct a program for Euler's method though this approach is not one of the best techniques to solve ODEs.
Heun's formula is used to solve the ODE which is given in the initial state [10,12]. Euler's method is the foundation of Heun's method. As we discussed earlier, Euler's method fails to converge in the case of a concave-up curve because it overestimates the next point. Heun's method solves this solution problem by taking two tangents on each side of the curve. One tangent underestimates and the other overestimates, and then, Heun's method estimates the next point from both tangents using Euler's method. Using (6), we can determine the numerical solution to the problem of initial values using the following method: where k 1 and k 2 are under-and overestimates. e step size is denoted by h, and initial conditions are x i and y i . e accuracy of Euler's method improves linearly as step size decreases but the accuracy of Heun's method improves quadratically [10,[12][13][14][15].

Derivations
While using the elementary idea that the line's slope equals its rise over run, the parameters at the endpoint can be calculated using the following symbolic development: Using Euler's method, the next point in the numerical solution is estimated roughly, and the initial estimation could be predicted or corrected using this information. erefore, we can calculate the slope of the prediction line by taking the average of the slopes of the left and right tangent lines, at either end of the interval. e values of the f (x, y) on the right-hand side of Equation (7) can be determined [16]. Following a rough estimate of the location of the next solution point from Euler's method, the coordinates may be used to determine the slope of the tangent line at the right end of the interval.

Modified Algorithm.
e initial or boundary conditions must be given for both the algorithm and the flowchart, as follows: (1) Start (2) Define function for slope calculation f (x, y) (3) State variables (4) Input value (5) Find slope while using initial value (6) Find new y, y � y0 + m0 × h (7) Increase value of x, which is x1 � x0 + h (8) Find new slope using x1 and y e updated Euler's method algorithm and owchart are described in Figure 2. ey may be used to produce source code in any high-level programming language.
In the case of complex problems, analytical methods frequently fail; however, Heun's method does not fail but provides better solution accuracy and high speed. It also improves Euler's technique with a lengthy code where we can pick a lower number of h to get high accuracy.

Piecewise Method
Nonlinear programming is used to solve a variety of optimization issues in science and technology. Piecewise linearization methods are used in recent years to turn nonlinear programming into linear programming or a mixed convex programming problem to get the desired solution [16][17][18][19]. e piecewise function is a hybrid function that is de ned by numerous subfunctions and each corresponding to a different interval of the main function domain or a subdomain. Piecewise can describe the nature of the function rather than just be a way of expressing it. In addition, the term piecewise can also refer to any piecewise-defined function that applies to each piece but may not be applicable for the whole function.
e piecewise or continuous differentiable behavior of a function is that each piece is differentiable within its domain, regardless of whether the whole function is differentiable at the intersection. When functions are analyzed convexly, the notation of a derivative can be replaced by that of the subderivative [17]. A function can indeed be described as "piecewise linear" or "piecewise continuous" or "piecewise differentiable" even if the pieces are not intervals. Equation (8) shows a piecewise notation that expresses the absolute value function as follows: To turn negative values into positive, the first function -x is used for all x values, and this invalidates the sign of the input value. e second function x is applied for all x values which could be larger than or equal to zero.

Linear Piecewise.
e piecewise linear function is a collection of quadratic functions, each defined on a set of intervals of real numbers. A finite collection of such intervals must exist if the domain of the function will either need to be finite or be locally finite [20][21][22][23].
ere are several contexts in which piecewise linear functions are relevant. In general, the piecewise linear function can be defined on any vector space or affine space and simplicial complexes [18,19,24]. A linear function is not simply a linear transformation, but in these contexts, it is an affine linear function. ere are two major subclasses of a piecewise linear function, called continuous and convex. As we can see from (9), every n-dimensional continuous function, in general, will have the following formulas:

Conclusion
We provided a class of numerical approaches for approximating the solutions of differential equations in this study which are based on a modified version. When applied to ODEs, these approaches yield a continuous approximate solution that is accurate to order 2n at the nodes and to order n + 1 evenly over the interval. To extend the approaches to delay differential equations, some a posteriori tweaks boost the uniform accuracy to order 2n. Real-world issues are subjected to numerical testing and compared with other methodologies. Four methods have been presented for linear system integration of ODEs, and those methods require less memory and less computational effort than the low storage methods. e notations and formulations have been studied in such a way that subsequent development of the theory of differential equations will follow the structure of ODEs. We also presented that when a nonstandard piecewise function is used correctly, it produces fractional-order differential equations that converge to the original equation as the parameter leads to zero. Even though it was not developed from quadrature, the method has been demonstrated to be equivalent to quadrated-based methods. Nonuniform time steps can be used to accomplish the approach. e difference equation may appropriately describe the dynamics of the underlying fractional differential equation, as demonstrated in the formulas.

Data Availability
Data will be shared on request.

Conflicts of Interest
e authors declare that they have no conflicts of interest.