November 1st, 2010, 8:46 pm
@wileysw:That can be done in Maple as well, though it does not have the command 'RootApproximant'.One defines a 'base' (which is one for transcendent input, not otherwise in general) bypowers and seeks for integer relations (with small numerical errors, thus depending onthe computational precision used), for which a variant of LLL is used.ApproxAlgebraicRelation:= proc(z,deg:osint, x)# z = any constant, # deg = desired degree for an approximate algebraic relation, # x = indeterminate to be used in the polynomiallocal w,u;#Digits:= Digits+3; # make your choice, Digits:= 2*Digits is finew:=Vector(deg+1, 'k -> z^(k-1)'); # = 1, z, z^2, z^3 ... w:=convert(%, list); # syntax needed for the following commandu:=IntegerRelations:-LinearDependency(evalf(w));0=sum( u[ i]*x^(i-1),i=1..deg+1); end proc;Using 14 digits (i.e. ~ hardware double precision) that replies by0 = -4491-13581*x+4778*x^2 for input z=Pi and variable x, degree=2.That says: Pi 'almost' satisfies that quadric. Within that code one can increase the accuracy - that leads to better results, but somelarger coefficients. And if one wants the 'most simple' one just increase degree, untilthe error falls below a limit (so there is a kind of trade off in combining degree andaccuracy (leading to longer expressions), what one wants to call 'most simple' ...).But that 'simple' approach is unlikely to produce those nice & curious results with veryhigh accuracy given at the Mathworld.@Cuchulainn:That 'rationalize' is degree=1, so can be done by LLL. However that is not needed at all.Essentially it (depending on computational precision) an iterated divison with remainder,until the remainder is 'killed' by the 'system epsilon' (~ precision). Silently you useit every day while coding ... (though it may differ from IEEE for other reasons).
Last edited by
AVt on October 31st, 2010, 11:00 pm, edited 1 time in total.