Approximation of a function from taylor series (Symbolic Toolbox)

4 Ansichten (letzte 30 Tage)
Matt Robinson
Matt Robinson am 21 Mär. 2018
Bearbeitet: John D'Errico am 22 Mär. 2018
Hi Everyone,
I have a question regarding Matlab, I have been creating algorithms to compute the numerical approximations of systems of differential equations using Picard's iterative method. The Algorithm works fine and it has been designed to deal with 3 different initial value problems 'x', 'y' and 'z'.
The method produces 3 approximation Taylor Series (initial value at x = 0 so technically Maclaurin Series). However I need to displays these approximation function in a 3D plot. To do that I need to find the analytical approximation of each Taylor series so that I can plot them using fplot3. Does anyone know how to do this?
One of the (very large) Taylor series that was calculated is the following
1 + 2*t - 4*t^2 - (19*t^3)/3 + t^4/12 + (191*t^5)/60 + (371*t^6)/360 - (167*t^7)/360 - (6049*t^8)/20160 - (409*t^9)/181440 + (59671*t^10)/1814400 + (1603*t^11)/259200 - (349849*t^12)/239500800 - (25117*t^13)/40435200
  3 Kommentare
Matt Robinson
Matt Robinson am 21 Mär. 2018
I suppose I have explained it very well. I have approximated the solutions to a system of differential equations x'(t), y'(t) and z'(t).
The solutions are 3 Taylor series x(t), y(t) and z(t) and before I can plot the solutions I need to simply them to an analytical solution as the fplot3 for x y and z provides a horrible plot.
Torsten
Torsten am 22 Mär. 2018
I don't understand why you do not just plot x against t, y against t and z against t.
Best wishes
Torsten.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

John D'Errico
John D'Errico am 22 Mär. 2018
Bearbeitet: John D'Errico am 22 Mär. 2018
Well, you have explained your question. But that does not say that your question has a solution.
You have three functions, all a function of t. So these are solutions of a system of ODEs.
First, does it make sense to want to plot them as a 3-d plot? They are all functions of t. They are NOT independent functions. So a simple plot of three functions all against t would seem sufficient. But if you wanted to plot the result as a parametric relationship in 3-d, you can do that using plot3. Just generate a vector of values for t.
t = 0:10;
X = 1 + 2*t - 4*t.^2 - (19*t.^3)/3 + t.^4/12 + (191*t.^5)/60 + ...
Note that I did not write the entire function. Too long for me, and why bother? I did use the .^ operator there, because t is a vector. That is important.
Then compute Y(t) and Z(T), in the same way, using their own truncated polynomials. PLot all three at once using plot3.
Remember of course, they are only approximate solutions. A Taylor series has infinitely many terms. These are TRUNCATED Taylor series.
If those TRUNCATED Taylor series are not sufficiently accurate when using fplot to describe the solution, that implies there are convergence problems. After all, if the series was adequate, you would not be complaining and hoping for a magical solution based on some unknown mathematics.
Most likely, as t gets large, these series are not adequately convergent. You would need to have gained more terms in the expansion. The last term in the series you show is:
(25117*t^13)/40435200
But for virtually any value of t at all that exceeds 1, this term will be significantly large.
t = 1.5;
(25117*t^13)/40435200
ans =
0.120891158030583
Were t as large as 2, it would in fact start to dominate the computation.
For a truncated series to be of value as an approximation, you need those high order terms to go to zero quickly enough that the truncated terms are insignificant.
And of course, this brings up the problem of polynomial accuracy in a double precision world. Simply evaluating those polynomials using double precision arithmetic will become problematic for sufficiently large values of t. So just taking more terms in that series will not help.
Any function that approximates this Taylor series would be inadequate anyway, as the function that best approximates that series is the truncated polynomial itself. Essentially, there is information lost when you truncate a series. You cannot somehow regain that information. There is no magic here.
Your real question seems to be to find the underlying function, given only the Taylor series. Here is where you will hit a brick wall of mathematical impossibility.
It is simply impossible to find the "function" that would have resulted in any given truncated Taylor series. In fact, there are infinitely many such possible functions. And most of those potential candidate functions have no names in mathematics, no analytical definition. It is not true that all functions have been defined, that all possible functions have a name. In fact, almost all functions have no name at all, have no definition. Only a vanishing few of them have ever been defined in mathematics.
In rare cases, the solution to some differential equation or other problem has been defined as a function. So there are special functions, ranging from trig functions & hyperbolic trig functions, to the error function (erf and its kissing cousin, erfc), Bessel functions, Lambert W, etc. And there are lots of polynomial families, but they don't really count in this respect, since you already have a polynomial. I could waste my time extending that list with others of course. But that limited set, however large is really only a very small set, compared to the uncountable infinities of functions that could be created, each of which has their own special behaviors.
So I am sorry, but it really is not possible to infer the original "function" from a truncated series. There really is no magical inversion process, wherein you can infer the original function, given only a series approximation.
There are limitations to using series approximations to an ODE. Of course, there are other solution methods, but all have their own limitations. If mathematics was easy, then some of us would take up more interesting avocations.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by