readme, fixup

This commit is contained in:
wan-may 2023-10-08 13:20:14 -03:00
parent 98c27e0725
commit 9a33c2b3a7
3 changed files with 37 additions and 10 deletions

View File

@ -3,7 +3,7 @@
local ORDER = 100
local binCoefs = {}
--memoized binonmial coefficient
local function Choose( n, k )
if k < 1 then return 1 end
if n < 1 then return 0 end

View File

@ -72,17 +72,24 @@ local function PlotFunction( f, color )
love.graphics.translate( - plot.x, - plot.y )
love.graphics.setLineWidth( 0.003 * (plot.X - plot.x) )
love.graphics.setColor( 0.5, 0.5, 0.5, 0.3 )
love.graphics.line( -10, -10, 10, 10 )
love.graphics.line( -10, 0, 10, 0 )
love.graphics.line( 0, -10, 0, 10 )
if color then love.graphics.setColor( color ) end
love.graphics.line( plot.inverse and inverse or points )
love.graphics.circle( "fill", a, a, 0.003 * (plot.X - plot.x) )
love.graphics.pop()
love.graphics.setFont( love.graphics.getFont( 48 ) )
love.graphics.print( a )
love.graphics.print( plot.fdbOrder, 0, 15 )
love.graphics.print( f(a), 0, 30 )
love.graphics.print( f(-1.0), 0, 45 )
love.graphics.setColor( 1,1,1,1 )
love.graphics.setFont( love.graphics.getFont( 48 ) )
end
end
@ -92,7 +99,7 @@ love.wheelmoved = function( x, y )
end
love.mousepressed = function(x, y, button)
--plot.inverse = not( plot.inverse )
plot.inverse = not( plot.inverse )
plot.fdbOrder = plot.fdbOrder + (( button == 1 ) and 1 or -1 )
return love.keypressed()
end
@ -116,18 +123,15 @@ love.keypressed = function( key, code )
love.draw = nil
local f, df, fn = Poly( FaaDiBruno( a, plot.fdbOrder ) )
--PlotFunction( f, {1, 0, 0, 0.3} ) --Function in red.
--PlotFunction( df, {0, 1, 0, 0.3} ) --First derivative in green.
--local lowF, lowDF = Poly( FaaDiBruno( a, 15 ) )
--PlotFunction( lowF, {1, 0, 0, 0.3} ) --Function in red.
--PlotFunction( lowDF, {0, 1, 0, 0.3} ) --First derivative in green.
PlotFunction( f, {1, 0, 0, 0.7} ) --Function in red.
PlotFunction( df, {0, 1, 0, 0.7} ) --First derivative in green.
--PlotFunction( function(x) return df( f ( x ) ) end, {0, 0, 1, 0.3})
--PlotFunction( function(x) return f( df ( x ) ) end, {1, 1, 1, 0.3})
--PlotFunction( function(x) return x end, {1, 1, 1, 0.3})
local af, an = Poly( Ansatz.coefs )
PlotFunction( af, {1,1,1, 0.3} )
PlotFunction( an, {1,1,1, 0.3} )
--PlotFunction( af, {1,1,1, 0.3} )
--PlotFunction( an, {1,1,1, 0.3} )
PlotFunction( Ansatz.dpo, {1, 1, 1, 0.3} )
PlotFunction( Ansatz.pos, {1,1,1,0.3} )
end

23
readme.md Normal file
View File

@ -0,0 +1,23 @@
Bespoke script for calculating and plotting some series solutions
of the functional equation f'( f( x ) ) = x.
Idea: suppose f has fixed point p,
apply the chain rule to functional equation
get values of f's derivatives at p
get truncated taylor series expansion of f at p,
plot series to get some idea about values, convergence.
We use Faa Di Bruno's formula for iterated derivatives, in terms of Bell numbers.
We also plot the "ansatz" solution, i.e. the solution of the form x -> a * x ^ b where a and b are positive.
Uses LOVE as a dependency for its plotting: https://love2d.org
Solution is plotted in red, first derivative is plotted in green.
Keys:
Q - Increase p
E - Decrease p
WASD - Translate view
Z - Zoom in
C - Zoom out
F - Increase order of series expansion
R - Decrease order