How does matlab provide precise Taylor expansions for some truncation order?

3 views (last 30 days)
In ordinary C language programming, dealing with fraction often causes some errors due to floating-point expression problems. Taylor expansion by nature has factorials in denominators, so how does Matlab deal with them when computing Taylor series up to certain truncation order (e.g. computing taylor series up to t^10, or t^20 for a function cos(t), where 10 or 20 would be truncation order)?

Accepted Answer

Walter Roberson
Walter Roberson on 14 Nov 2015
sin() and cos() of single precision or double precision numbers are handed to the hardware to evaluate, such as Intel's FSIN and FCOS instructions. MATLAB has no control over the CPU's computation methods, so the accuracy is limited by the hardware implementation
But taylor() is part of the Symbolic Toolbox, which uses software arithmetic, and so is not limited by double precision constraints. The symbolic toolbox has no problem with calculating 20! exactly or doing a division whose accuracy is bounded by the number of Digits that is currently in effect.

More Answers (1)

James Tursa
James Tursa on 13 Nov 2015
Edited: James Tursa on 13 Nov 2015
Not sure what you are really asking here. There is a taylor function in the Symbolic Toolbox that does such expansions for whatever order you want. Then of course you could use that as the basis for a calculation with doubles, and you would get whatever you get as far as the calculation error was concerned.
But for the actual library functions such as cos and sin that are called for doubles, it isn't necessarily going to be the case at all that a Taylor series expansion is used. It could be some form of input range reduction followed by a rational function approximation is used, for instance. So your question about Taylor series truncation order wouldn't even apply.

Products

Community Treasure Hunt

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

Start Hunting!