## dmj5 Class DMJ_Simurgh

```Object
common:Generic
common:Formula
common:DivergentFormula
dmj5:DMJ_Simurgh
```

`class DivergentFormula:DMJ_Simurgh`

Simurgh/Phoenix/Double Mandelbrot Family This fractal type encompasses many variants in the Mandelbrot family of fractals. The basic Mandelbrot equation is: z[n+1] = z[n]^a + c where z[0]=0, a=2 and c varies with pixel location. The Phoenix fractal discovered by Shigehiro Ushiki in 1988 is a variation of this, where the input of two iterations is used: z[n+1] = z[n]^a + c*z[n]^d + p*z[n-1] The classical Phoenix fractal is the Julia form, where z[0] varies with pixel, d=0, c=0.56667, and p=-0.5. Note that if d=0 and p=0, the classical Mandelbrot equation is still there. So Phoenix fractals are a superset of the Mandelbrot fractals. The Simurgh fractal is a fairly straightforward extension of the idea I wrote in November 1999; it uses three iterations as input: z[n+1] = z[n]^a + c*z[n]^d + p*z[n-1] + q*z[n-2] If q=0, the Phoenix equation emerges, so again Simurgh fractals are a superset of Phoenix fractals. A different direction of extension to the classical Mandelbrot extension is DoubleMandel, which uses two separately-scaled z[n] terms: z[n+1] = s*z[n]^a + t*z[n]^b + c We can include this extension into the Simurgh equation: z[n+1] = s*z[n]^a + t*z[n]^b + c*z[n]^d + p*z[n-1] + q*z[n-2] This becomes the Simurgh equation when s=1 and t=0, so again it is a superset. The above equation is the one used in this formula.

Ultra Fractal Source
``` class DMJ_Simurgh(common.ulb:DivergentFormula) {
;
; Simurgh/Phoenix/Double Mandelbrot Family
;
; This fractal type encompasses many variants in the
; Mandelbrot family of fractals. The basic Mandelbrot
; equation is:
;
;     z[n+1] = z[n]^a + c
;
; where z[0]=0, a=2 and c varies with pixel location. The
; Phoenix fractal discovered by Shigehiro Ushiki in 1988
; is a variation of this, where the input of two iterations
; is used:
;
;     z[n+1] = z[n]^a + c*z[n]^d + p*z[n-1]
;
; The classical Phoenix fractal is the Julia form, where
; z[0] varies with pixel, d=0, c=0.56667, and p=-0.5. Note
; that if d=0 and p=0, the classical Mandelbrot equation
; is still there. So Phoenix fractals are a superset of
; the Mandelbrot fractals.
;
; The Simurgh fractal is a fairly straightforward extension
; of the idea I wrote in November 1999; it uses three
; iterations as input:
;
;     z[n+1] = z[n]^a + c*z[n]^d + p*z[n-1] + q*z[n-2]
;
; If q=0, the Phoenix equation emerges, so again Simurgh
; fractals are a superset of Phoenix fractals.
;
; A different direction of extension to the classical
; Mandelbrot extension is DoubleMandel, which uses two
; separately-scaled z[n] terms:
;
;     z[n+1] = s*z[n]^a + t*z[n]^b + c
;
; We can include this extension into the Simurgh equation:
;
;     z[n+1] = s*z[n]^a + t*z[n]^b + c*z[n]^d + p*z[n-1] + q*z[n-2]
;
; This becomes the Simurgh equation when s=1 and t=0, so
; again it is a superset. The above equation is the one used
; in this formula.
;

public:
import "common.ulb"

func DMJ_Simurgh(Generic pparent)
Formula.Formula(pparent)
endfunc

complex func Init(complex pz)
Formula.Init(pz)

m_Seed = pz
m_W = (0,0)
m_Y = (0,0)
m_ZNew = (0,0)

return @p_start
endfunc

complex func Iterate(complex pz)
Formula.Iterate(pz)

m_ZNew = @p_coeff1*pz^@p_power1 + @p_coeff2*pz^@p_power2 + m_Seed*pz^@p_power3 + @p_induct1 * m_Y + @p_induct2 * m_W
m_W = m_Y
m_Y = pz
return m_ZNew
endfunc

; Determine the primary exponent.
;
; Many fractals can be characterized by an exponent value that
; is useful to other formulas, so we provide that here. If
; your formula does not need or use this value, override the
; p_power parameter and make it hidden.
;
; @return the primary exponent parameter
complex func GetPrimaryExponent()
if (|@p_power1| > |@p_power2|)
return @p_power1
else
return @p_power2
endif
endfunc

protected:
complex m_Seed
complex m_W
complex m_Y
complex m_ZNew

default:
title = "Mandelbrot/Phoenix/Simurgh"

int param v_dmj_simurgh
caption = "Version (DMJ_Simurgh)"
default = 100
hint = "This version parameter is used to detect when a change has been made to the formula that is incompatible with the previous version. When that happens, this field will reflect the old version number to alert you to the fact that an alternate rendering is being used."
visible = @v_dmj_simurgh < 100
endparam

complex param p_power
visible = false
endparam

int param p_mode
caption = "Formula Type"
default = 0
enum = "Mandelbrot" "Phoenix" "Simurgh"
hint = "Sets the fractal type."
endparam
bool param p_double
caption = "Double variant"
default = false
hint = "If checked, enables the Double variant."
endparam

complex param p_start
caption = "Start Value"
default = (0,0)
hint = "Starting value for each point.  You can use this to 'perturb' the fractal."
endparam
complex param p_power1
caption = "1st Exponent"
default = (2,0)
hint = "Defines the primary exponent for the fractal. Use 2.0 for classical Mandelbrot and Phoenix."
endparam
complex param p_coeff1
caption = "1st Scale"
default = (1,0)
hint = "Defines the coefficient (multiplier) for the primary exponent term. Use 1.0 for classical Mandelbrot and Phoenix."
visible = (@p_double || @p_coeff1 != 1.0)
endparam
complex param p_power2
caption = "2nd Exponent"
default = (0,0)
hint = "Defines the secondary exponent for the fractal."
visible = (@p_double || @p_coeff2 != 0.0)
endparam
complex param p_coeff2
caption = "2nd Scale"
default = (0,0)
hint = "Defines the coefficient (multiplier) for the secondary exponent term. Use 0 for classical Mandelbrot and Phoenix."
visible = (@p_double || @p_coeff2 != 0.0)
endparam

complex param p_power3
caption = "Phoenix Exp."
default = (0,0)
hint = "Defines the exponent for constant term's multiplier. Use 0 for classical Mandelbrot and Phoenix."
visible = (@p_mode == 1 || @p_mode == 2 || @p_power3 != 0.0)
endparam
complex param p_induct1
caption = "Phoenix Dist."
default = (0,0)
hint = "Sets how 'strong' the previous iteration's effect should be on the fractal. Use -0.5 for classical Phoenix; use 0 for classical Mandelbrot."
visible = (@p_mode == 1 || @p_mode == 2 || @p_induct1 != 0.0)
endparam

complex param p_induct2
caption = "Simurgh Dist."
default = (0,0)
hint = "Sets how 'strong' the next previous iteration's effect should be on the fractal. Use 0 for classical Mandelbrot and Phoenix."
visible = (@p_mode == 2 || @p_induct2 != 0.0)
endparam

float param p_bailout
caption = "Bailout"
default = 1.0e20
hint = "Defines how soon an orbit bails out, i.e. doesn't belong to the fractal set anymore. Note: larger values result in more iterations being calculated."
endparam
}
```

Constructor Summary
`DMJ_Simurgh()`

`DMJ_Simurgh(Generic pparent)`

Method Summary
` complex` `GetPrimaryExponent()`
Determine the primary exponent.
` complex` `Init(complex pz)`
Set up for a sequence of values
` complex` `Iterate(complex pz)`
Produce the next value in the sequence

Methods inherited from class common:DivergentFormula
`GetUpperBailout, IsBailedOut`

Methods inherited from class common:Formula
`GetLowerBailout`

Methods inherited from class common:Generic
`GetParent`

Methods inherited from class Object

Constructor Detail

### DMJ_Simurgh

`public DMJ_Simurgh(Generic pparent)`

### DMJ_Simurgh

`public DMJ_Simurgh()`
Method Detail

### Init

`public complex Init(complex pz)`
Description copied from class: `DivergentFormula`
Set up for a sequence of values

This function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).

Overrides:
`Init` in class `DivergentFormula`
Parameters:
`pz` - seed value for the sequence; for a normal fractal formula, this will be #pixel
Returns:
first value in the sequence; this corresponds to #z in a fractal formula

### Iterate

`public complex Iterate(complex pz)`
Description copied from class: `Formula`
Produce the next value in the sequence

As long as the sequence has not bailed out, this function will be continually called to produce sequence values.

Overrides:
`Iterate` in class `Formula`
Parameters:
`pz` - previous value in the sequence; corresponds to #z in a fractal formula. Note that you should always use this value for computing the next iteration, rather than a saved value, as the calling code may modify the returned value before passing it back to the next Iterate() call.
Returns:
the next value in the sequence

### GetPrimaryExponent

`public complex GetPrimaryExponent()`
Determine the primary exponent. Many fractals can be characterized by an exponent value that is useful to other formulas, so we provide that here. If your formula does not need or use this value, override the p_power parameter and make it hidden.

Overrides:
`GetPrimaryExponent` in class `Formula`
Returns:
the primary exponent parameter