Following this link (with a working code in a Wolfram language):
http://demonstrations.wolfram.com/LyapunovFractals/[
^]
generating the image should be pretty straight forward:
Choose a string of As and Bs of any nontrivial length (e.g., AABAB).
Construct the sequence S formed by successive terms in the string, repeated as many times as necessary.
Choose a point
(a,b) \in [0,4] \times [0,4].
Define the function
r_n = a if S_n = A,
and
r_n = b if S_n = B.
Let x_0 = 0.5, and compute the iterates
x_{n+1} = r_n x_n (1 - x_n).
Compute the Lyapunov exponent:
\lambda = \lim_{N \rightarrow \infty} {1 \over N} \sum_{n = 1}^N \log \left|{dx_{n+1} \over dx_n}\right| = \lim_{N \rightarrow \infty} {1 \over N} \sum_{n = 1}^N \log |r_n (1 - 2x_n)|
In practice, \lambda is approximated by choosing a suitably large N.
Color the point (a,b) according to the value of \lambda obtained.
Repeat steps (3–7) for each point in the image plane.
LyapunovCanvas.Background = Nothing
Dim Sn As Char() = txtLyapunovGeneratingString.Text.ToString.ToCharArray
Dim LyapunovImageDimensions As Integer = 400
Dim LyapunovScaleFactor = 4 / LyapunovImageDimensions
Dim LyapunovLambdaArray(LyapunovImageDimensions + 1, LyapunovImageDimensions + 1) As Double
Dim MAxValue, MinValue As Double
MAxValue = Double.MinValue
MinValue = Double.MaxValue
Dim N As Integer = 180
Dim a, b As Double
For x As Integer = 0 To LyapunovImageDimensions
For y As Integer = 0 To LyapunovImageDimensions
a = LyapunovScaleFactor * x
b = LyapunovScaleFactor * y
Dim rn As Double = 0
Dim X0 As Double = 0.5
Dim Xn As Double = X0
Dim LyapunovExponent As Double = 0
For CharItem As Integer = 0 To Sn.Length - 1
rn = If(Sn(CharItem).ToString.ToUpper = "A", a, b)
Xn = 0.5
For NCount As Integer = 1 To N
LyapunovExponent += Math.Log(0.00001 + Math.Abs(rn * (1 - 2 * Xn))) / N
Xn = rn * Xn * (1 - Xn)
Next
Next
LyapunovLambdaArray(x, y) = LyapunovExponent
If MAxValue < LyapunovExponent Then
MAxValue = LyapunovExponent
End If
If MinValue > LyapunovExponent Then
MinValue = LyapunovExponent
End If
Next
Next
Dim buffer As New List(Of Byte)
For x As Integer = 0 To LyapunovImageDimensions
For y As Integer = 0 To LyapunovImageDimensions
Dim k As Integer = 0
Dim TempBrush As New SolidColorBrush
If LyapunovLambdaArray(x, y) > 0.1 Then
TempBrush = Brushes.Blue
ElseIf LyapunovLambdaArray(x, y) < 0.1 Then
TempBrush = Brushes.Yellow
Else
TempBrush = Brushes.Black
End If
buffer.Add(TempBrush.Color.B)
buffer.Add(TempBrush.Color.G)
buffer.Add(TempBrush.Color.R)
buffer.Add(TempBrush.Color.A)
Next
Next
Dim dpiX As Double = 96D
Dim dpiY As Double = 96D
Dim pixelFormat = PixelFormats.Pbgra32
Dim bytesPerPixel = Math.Truncate(((pixelFormat.BitsPerPixel + 7) / 8))
Dim stride = bytesPerPixel * (LyapunovImageDimensions + 1)
Dim img As New ImageBrush
img.ImageSource = BitmapSource.Create(LyapunovImageDimensions, LyapunovImageDimensions, dpiX, dpiY,
pixelFormat, Nothing, buffer.ToArray, stride)
LyapunovCanvas.Background = img
But the images that are created looks nothing like they should. Can anyone spot my mistake here?