progs/mandelbrot.sc
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 06 Jun 2024 19:14:33 +0100
changeset 489 d51cacc92480
parent 488 5deaf53c2faa
permissions -rw-r--r--
updated to Scala 3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
// Mandelbrot pictures
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
//=====================
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
//
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
//   see https://en.wikipedia.org/wiki/Mandelbrot_set
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
     5
//
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
// needs to be called with
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
     7
//
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
     8
//   scala-cli --extra-jars scala-parallel-collections_3-1.0.4.jar
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
     9
//
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    10
// the jar-file is uploaded to KEATS
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
//
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    12
//
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    13
// !! UPDATE ON TIMING: On my faster Mac-M1 machine 
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    14
// !! the times for the first example are ca. 4 secs for 
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    15
// !! the sequential version and around 0.7 secs for the 
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    16
// !! par-version.
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    19
import javax.swing.{JFrame, JPanel, WindowConstants}
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    20
import java.awt.{Color, Dimension, Graphics, Graphics2D}
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
import java.awt.image.BufferedImage
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    22
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    23
import scala.language.implicitConversions
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    24
import scala.collection.parallel.CollectionConverters.*
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
// complex numbers
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    27
// represents the complex number re + im * i
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    28
case class Complex(val re: Double, val im: Double) {
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    29
  
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
  def +(that: Complex) = Complex(this.re + that.re, this.im + that.im)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
  def -(that: Complex) = Complex(this.re - that.re, this.im - that.im)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
  def *(that: Complex) = Complex(this.re * that.re - this.im * that.im,
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
                                 this.re * that.im + that.re * this.im)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    34
  def *(that: Double) = Complex(this.re * that, this.im * that)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
  def abs() = Math.sqrt(this.re * this.re + this.im * this.im)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
}
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    38
// to allow the usual mathmo notation n + m * i
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
object i extends Complex(0, 1)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    41
// implicit conversion from Doubles to Complex
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    42
given Conversion[Double, Complex] = Complex(_, 0)
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    43
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    44
// some customn colours for the "sliding effect"
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    45
val colours = List(
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    46
  Color(66, 30, 15),    Color(25, 7, 26),
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    47
  Color(9, 1, 47),      Color(4, 4, 73),
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    48
  Color(0, 7, 100),     Color(12, 44, 138),
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    49
  Color(24, 82, 177),   Color(57, 125, 209),
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    50
  Color(134, 181, 229), Color(211, 236, 248),
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    51
  Color(241, 233, 191), Color(248, 201, 95),
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    52
  Color(255, 170, 0),   Color(204, 128, 0),
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    53
  Color(153, 87, 0),    Color(106, 52, 3))
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    55
// the viewer panel with an image canvas
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
class Viewer(width: Int, height: Int) extends JPanel {
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    57
  val canvas = BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB)
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    58
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    59
  override def paintComponent(g: Graphics) =
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    60
    g.asInstanceOf[Graphics2D].drawImage(canvas, null, null)
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    61
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    62
  override def getPreferredSize() =
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    63
    Dimension(width, height)
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    64
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    65
  def clearCanvas(color: Color) = {
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    66
    for (x <- 0 to width - 1; y <- 0 to height - 1)
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
      canvas.setRGB(x, y, color.getRGB())
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    68
    repaint()
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    69
  }
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    70
}
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
// initialising the viewer panel
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
def openViewer(width: Int, height: Int) : Viewer = {
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    74
  val frame = JFrame("XYPlane")
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    75
  val viewer = Viewer(width, height)
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
  frame.add(viewer)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    77
  frame.pack()
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
  frame.setVisible(true)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
  frame.setResizable(false)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
  viewer
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
}
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    83
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    84
// some hardcoded parameters
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    85
val W = 900   // width
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    86
val H = 800   // height
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    87
val black = Color.black
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    88
val viewer = openViewer(W, H)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    89
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    90
// draw a pixel on the canvas
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    91
def pixel(x: Int, y: Int, color: Color) =
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    92
  viewer.canvas.setRGB(x, y, color.getRGB())
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    93
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    94
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    95
// calculates the number of iterations using lazy lists (streams)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    96
//   the iteration goes on for a maximum of max steps,
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    97
//   but might leave early when the pred is satisfied
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    98
def iterations(c: Complex, max: Int) : Int = {
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
    99
  def next(z: Complex) = z * z + c
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   100
  def pred(z: Complex) = z.abs() < 2    // exit condition
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   101
  LazyList.iterate(0.0 * i, max)(next).takeWhile(pred).size
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   102
}
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   103
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   104
// main function
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   105
//    start and end are the upper-left and lower-right corners,
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   106
//    max is the number of maximum iterations
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
def mandelbrot(start: Complex, end: Complex, max: Int) : Unit = {
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   108
  viewer.clearCanvas(black)
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   109
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   110
  // deltas for each grid step
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
  val d_x = (end.re - start.re) / W
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
  val d_y = (end.im - start.im) / H
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   113
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   114
  for (y <- (0 until H).par) {
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   115
    for (x <- (0 until W).par) {
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   116
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   117
     val c = start + x * d_x + y * d_y * i
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   118
     val iters = iterations(c, max)
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   119
     val colour = 
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   120
        if (iters == max) black
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   121
        else colours(iters % 16)
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   122
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   123
     pixel(x, y, colour)
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   124
    }
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   125
    viewer.updateUI()
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   126
  }
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
}
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   129
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
// Examples
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   131
//==========
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   133
//for measuring time
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   134
def time_needed[T](code: => T) = {
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   135
  val start = System.nanoTime()
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   136
  code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   137
  val end = System.nanoTime()
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   138
  (end - start) / 1.0e9
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   139
}
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   140
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   141
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   142
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   143
// example 1
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   144
val exa1 = -2.0 + -1.5 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
val exa2 =  1.0 +  1.5 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   147
println(s"${time_needed(mandelbrot(exa1, exa2, 1000))} secs")
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   148
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   149
// example 2
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   150
val exb1 = -0.37465401 + 0.659227668 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   151
val exb2 = -0.37332410 + 0.66020767 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   153
//time_needed(mandelbrot(exb1, exb2, 1000))
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   154
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   155
// example 3
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
val exc1 = 0.435396403 + 0.367981352 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
val exc2 = 0.451687191 + 0.380210061 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   159
//time_needed(mandelbrot(exc1, exc2, 1000))
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   160
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   161
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   162
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   163
// some more computations with example 3
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   164
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   165
val delta = (exc2 - exc1) * 0.0333
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   166
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   167
println(s"${time_needed(
489
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   168
  for (n <- (0 to 25))
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   169
     mandelbrot(exc1 + delta * n,
d51cacc92480 updated to Scala 3
Christian Urban <christian.urban@kcl.ac.uk>
parents: 488
diff changeset
   170
                exc2 - delta * n, 1000))} secs")
484
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   171
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   172
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   173
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   174
// Larry Paulson's example
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   175
val exl1 = -0.74364990 + 0.13188170 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   176
val exl2 = -0.74291189 + 0.13261971 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   177
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   178
//println(s"${time_needed(mandelbrot(exl1, exl2, 1000))} secs")
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   179
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   180
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   181
// example by Jorgen Villadsen
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   182
val exj1 = 0.10284 - 0.63275 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   183
val exj2 = 0.11084 - 0.64075 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   184
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   185
//time_needed(mandelbrot(exj1, exj2, 1000))
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   186
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   187
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   188
// another example
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   189
val exA = 0.3439274 + 0.6516478 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   190
val exB = 0.3654477 + 0.6301795 * i
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   191
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   192
//time_needed(mandelbrot(exA, exB, 1000))