Maple code
This is a Maple code sample that I used to develop my hypothesis about the continued fraction.
# here is what I saw that confirmed the fraction
# for e^x
get_fraction:= proc(ff)
local gg,nn,hh;
# get the coefficient of x^0
gg:=coeff(ff,x,0):
# subtract the x^0 and do the division
hh:=taylor(x/(ff-gg),x=0,30):
# pull out the coeff of x^0
gg:=simplify(coeff(hh,x,0)):
# return the coeff of x^0 and the current fraction
return (gg,hh);
end proc;
iterate_sequence := proc(aa)
local ii, bb,cc,dd;
bb:=aa:
# iterate through 15 divisions
for ii from 1 by 1 to 15 do
(dd,cc) := get_fraction(bb):
bb := cc:
print(ii,"===",dd);
end do;
end proc;
w:=taylor( exp(x), x=0, 30 );
iterate_sequence (w);
#########################################################
# this is a general case.
# you can see the determinants in the first
# few terms.
restart;
y:=sum(a[i]*x^i,i=0..10);
trya := proc(ff)
local gg,nn,hh;
gg:=coeff(ff,x,0):
hh:=taylor(x/(ff-gg),x=0,10):
gg:=simplify(coeff(hh,x,0)):
return (gg,hh);
end proc;
tryb := proc(aa)
local ii, bb,cc,dd;
bb:=aa:
for ii from 1 by 1 to 12 do
(dd,cc) := trya(bb):
bb := cc:
print(ii,"===",dd);
end do;
end proc;
tryb(y);
################################################
# This is a test of the general case where the
# actual determinants are computed.
# This is an implementation of my hypothesis.
#
restart;
with(LinearAlgebra);
# Generate the functions which are the determinants
fun := proc(i,j)
local A;
if i=0 and j=0 then
return 1;
end if;
if i=1 and j=0 then
return a[0];
end if;
if i=1 and j=1 then
return a[1];
end if;
if i=2 and j=1 then
return a[2];
end if;
A:=(x,y) -> a[x+y-2+i];
return Determinant(Matrix(j,A));
# return (Matrix(j,A));
end proc;
coef := proc(n)
local C,size;
if n=0 then
return a[0];
end if;
if n=1 then
return 1/a[1];
end if;
if type(n,even) then
size:=n/2;
return -(fun(1,size))^2/(fun(2,size-1)*fun(2,size));
else
size:=(n-1)/2;
return (fun(2,size))^2/(fun(1,size)*fun(1,size+1));
end if;
end proc;
# print the
for i from 0 by 1 to 10 do
v[i]:=coef(i);
end do;
# test with e^x
# set the values for a[i] to be the values
# for the taylor series for e^x
for i from 0 by 1 to 30 do
a[i] := 1/i!;
end do;
# now, let's see what the values are for the
# continued fraction
for i from 0 by 1 to 10 do
v[i];
end do;
|