numapprox
confracform
convert a rational function to continued-fraction form
Calling Sequence
Parameters
Description
Examples
confracform(r)
confracform(r, x)
r
-
procedure or expression representing a rational function
x
(optional) variable name appearing in r, if r is an expression
This procedure converts a given rational function r into the continued-fraction form which minimizes the number of arithmetic operations required for evaluation.
If the second argument x is present then the first argument must be a rational expression in the variable x. If the second argument is omitted then either r is an operator such that r⁡y yields a rational expression in y, or else r is a rational expression with exactly one indeterminate (determined via indets).
Note that for the purpose of evaluating a rational function efficiently (i.e. minimizing the number of arithmetic operations), the rational function should be converted to continued-fraction form. In general, the cost of evaluating a rational function of degree m,n when each of numerator and denominator is expressed in Horner (nested multiplication) form, with the denominator made monic, is
m+n mults/divs and m+n adds/subtracts
whereas the same rational function can be evaluated in continued-fraction form with a cost not exceeding
max⁡m,n mults/divs and m+n adds/subtracts
The command with(numapprox,confracform) allows the use of the abbreviated form of this command.
with⁡numapprox:
f≔t↦1.1⋅t2−20.5⋅t+5.3t2+7.6⋅t+0.1
The Horner form can be evaluated in 4 mults/divs
hornerform⁡f
t↦5.3+−20.5+1.1⋅t⋅t0.1+7.6+t⋅t
whereas the continued-fraction form can be evaluated in 2 mults/divs
confracform⁡f
y↦1.100000000−28.86000000y+7.779833680+1.499076119y−0.1798336798
e≔pade⁡exp⁡x,x,2,2
e≔112⁢x2+12⁢x+1112⁢x2−12⁢x+1
confracform⁡e,x
1+12x−6+12x
r2,3≔minimax⁡tan⁡xx,x=0..π4,2,3
r2,3≔1.130422926+−0.07842798254−0.07066118710⁢x⁢x1.130423032+−0.07843711579+−0.4473405792+0.02547897687⁢x⁢x⁢x
confracform⁡r2,3
−2.773313366x−18.66715865+33.63826614x+8.668760300+49.52801799x−7.558844295
See Also
convert/confrac
indets
numapprox[hornerform]
Download Help Document