commit 099b8440e258e2756a85020b4202a018de0f0047 Author: yaw-man Date: Tue Feb 7 22:31:35 2023 -0400 Plotting diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..6c16bd9 --- /dev/null +++ b/main.lua @@ -0,0 +1,47 @@ +--Bespoke script for calculating one-parameter family of real analytic solutions +--to 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 to get some idea about values, convergence. + + +local function PlotFunction( f ) + + local RESOLUTION = 1000 + + local points = {} + for n = 1, RESOLUTION do + points[ 2 * n - 1 ] = n / RESOLUTION + points[ 2 * n ] = f( n / RESOLUTION ) + end + + local tf = love.math.newTransform( + 0, love.graphics.getHeight(), + 0, love.graphics.getWidth(), + -love.graphics.getHeight()) + + love.graphics.setColor( 1, 1, 1, 0.5 ) + love.graphics.setLineWidth( 0.003 ) + love.graphics.setLineJoin( "miter" ) + love.graphics.setLineStyle( "smooth" ) + local draw = love.draw or function() end + + love.draw = function() + draw() + love.graphics.replaceTransform( tf ) + love.graphics.line( points ) + end + + love.update = function( dt ) + print( love.mouse.getPosition( ) ) + end + +end + +PlotFunction( function( x ) return x * x end ) +PlotFunction( function( x ) return x * x * x end ) +PlotFunction( math.sin ) +PlotFunction( function( x ) return math.exp( x ) - 1 end ) \ No newline at end of file