Visualization using Python

Visualization using Python

It is hard to meet someone from the STEM areas that has never heard from the Taylor series. The Taylor series is a well-known mathematical tool, used pretty much as the backbone of many of today’s simulation methods – such as CFD, FEM analysis for solids, Process controlers and the list goes on.

In a nutshell, the Taylor series is an approximation for a function – be it a simple F(x)=x, a F(x)=sin(x) or a harder function – as long as you know the information on a point (such as the derivatives). Aside from fulfilling some other criteria, the approximation will turn out the most accurate the more terms are utilized.

This is an issue that exists for Taylor and Fourier series, and it has consequences on other methods. For example, by studying finite elements discretization, one central concern was about the number of terms utilized on the calculations – the higher the number of terms, the better is the result and the convergence (althought higher will be the computational costs), Ok, it is a simple rule to live by, but can the benefit of the additional terms be visualized?

Using Python, I made a simple animation visualizing how well the Taylor series based on a f(x)=sin(x) function conforms to its “mother function”. It is pretty satisfying to see how the Taylor series behave almost exactly as sin(x) in the proximities of the point I chose (x=1) the more terms were utilized. Of course, there is nothing special about x=1, as it could be basically any other point which informations are known.

And what about the difference of each point of the Taylor series with the actual function – in other words, the absolute error of the model for a given interval? In order to evaluate the errors, we can look onto some boxplots and histograms, but that is a subject for another post.

Software utilized: Spyder, Python 3.8 (libraries: Numpy, Matplotlib, Celluloid)

Sources: Computational Fluid Dynamics by John D. Anderson Jr. (McGrawHill/1995). Polinômios e suas séries by Ricardo Bianconi (Universidade de São Paulo/Rev August of 2015)


To view or add a comment, sign in

More articles by Ivan Tonon

  • Data Representation & Python

    Last post I used some of Numpy’s linear algebra package for calculations, Matplotlib’s graphics and a simple animation…

    2 Comments

Others also viewed

Explore content categories