Perturbation theory to speed up Julia fractal drawing











up vote
0
down vote

favorite












I have a really underpowered platform here and want to draw a Julia (and possibly Mandelbrot and Burning ship) fractals using a 8.24 fixed point class. I use iteration count for coloring and need to speed up rendering considerably. I read about perturbation theory (see this) and am trying to do the following:




  • Iteratively calculate one image pixel $X$ using $X_{n+1}=X_n+X_0$ until the iteration exits due to iteration
    limit or distance estimate ($|X_n| >= 2$). I calculate and store all
    values of $X_n$, $A_n$, $B_n$, $C_n$ on the way.

  • Then for the next 3 pixels I use $Delta_n = A_ndelta_i+B_ndelta_i²+C_ndelta_i³$, where $delta_i = pixelspace index *{horizontalspace range over nrOfPixels}$ (the "horizontal step value"). Then supposedly the (estimated) value for the new pixel should be $Y_n = X_n + Delta_n$. This is where the speedup should come from.

  • Then I use $Y_n$ and decide whether to iterate further if $|Y_n| < 2$, or if $|Y_n| >= 2$ "step backwards" (calculate $Y_{n-1}$ like above), to see if $Y_n$ would have exited in an earlier iteration (until $|Y_{n-1}| < 2$).


This should make the 3 pixels "I cheat on" much cheaper to calculate (if this works I'd use 4x4 pixel chunks). Question is: Should this work in theory? It is not really working for me and I'm trying to find out what I'm doing wrong. "Regular" per-pixel Julia rendering is working ok for 16.16 and 8.24 fixed-point formats, so I suspect it's not calculation errors piling up...
I can post C++ code if that helps.



enter image description here










share|cite|improve this question
























  • fractalforums.org/fractal-mathematics-and-new-theories/28/…
    – Adam
    Nov 17 at 20:38












  • How confident are you that your code for computing $A_n,B_n,C_n$ has no bugs?
    – Rahul
    Nov 18 at 14:22










  • mathr.co.uk/blog/…
    – Claude
    Nov 18 at 19:06















up vote
0
down vote

favorite












I have a really underpowered platform here and want to draw a Julia (and possibly Mandelbrot and Burning ship) fractals using a 8.24 fixed point class. I use iteration count for coloring and need to speed up rendering considerably. I read about perturbation theory (see this) and am trying to do the following:




  • Iteratively calculate one image pixel $X$ using $X_{n+1}=X_n+X_0$ until the iteration exits due to iteration
    limit or distance estimate ($|X_n| >= 2$). I calculate and store all
    values of $X_n$, $A_n$, $B_n$, $C_n$ on the way.

  • Then for the next 3 pixels I use $Delta_n = A_ndelta_i+B_ndelta_i²+C_ndelta_i³$, where $delta_i = pixelspace index *{horizontalspace range over nrOfPixels}$ (the "horizontal step value"). Then supposedly the (estimated) value for the new pixel should be $Y_n = X_n + Delta_n$. This is where the speedup should come from.

  • Then I use $Y_n$ and decide whether to iterate further if $|Y_n| < 2$, or if $|Y_n| >= 2$ "step backwards" (calculate $Y_{n-1}$ like above), to see if $Y_n$ would have exited in an earlier iteration (until $|Y_{n-1}| < 2$).


This should make the 3 pixels "I cheat on" much cheaper to calculate (if this works I'd use 4x4 pixel chunks). Question is: Should this work in theory? It is not really working for me and I'm trying to find out what I'm doing wrong. "Regular" per-pixel Julia rendering is working ok for 16.16 and 8.24 fixed-point formats, so I suspect it's not calculation errors piling up...
I can post C++ code if that helps.



enter image description here










share|cite|improve this question
























  • fractalforums.org/fractal-mathematics-and-new-theories/28/…
    – Adam
    Nov 17 at 20:38












  • How confident are you that your code for computing $A_n,B_n,C_n$ has no bugs?
    – Rahul
    Nov 18 at 14:22










  • mathr.co.uk/blog/…
    – Claude
    Nov 18 at 19:06













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a really underpowered platform here and want to draw a Julia (and possibly Mandelbrot and Burning ship) fractals using a 8.24 fixed point class. I use iteration count for coloring and need to speed up rendering considerably. I read about perturbation theory (see this) and am trying to do the following:




  • Iteratively calculate one image pixel $X$ using $X_{n+1}=X_n+X_0$ until the iteration exits due to iteration
    limit or distance estimate ($|X_n| >= 2$). I calculate and store all
    values of $X_n$, $A_n$, $B_n$, $C_n$ on the way.

  • Then for the next 3 pixels I use $Delta_n = A_ndelta_i+B_ndelta_i²+C_ndelta_i³$, where $delta_i = pixelspace index *{horizontalspace range over nrOfPixels}$ (the "horizontal step value"). Then supposedly the (estimated) value for the new pixel should be $Y_n = X_n + Delta_n$. This is where the speedup should come from.

  • Then I use $Y_n$ and decide whether to iterate further if $|Y_n| < 2$, or if $|Y_n| >= 2$ "step backwards" (calculate $Y_{n-1}$ like above), to see if $Y_n$ would have exited in an earlier iteration (until $|Y_{n-1}| < 2$).


This should make the 3 pixels "I cheat on" much cheaper to calculate (if this works I'd use 4x4 pixel chunks). Question is: Should this work in theory? It is not really working for me and I'm trying to find out what I'm doing wrong. "Regular" per-pixel Julia rendering is working ok for 16.16 and 8.24 fixed-point formats, so I suspect it's not calculation errors piling up...
I can post C++ code if that helps.



enter image description here










share|cite|improve this question















I have a really underpowered platform here and want to draw a Julia (and possibly Mandelbrot and Burning ship) fractals using a 8.24 fixed point class. I use iteration count for coloring and need to speed up rendering considerably. I read about perturbation theory (see this) and am trying to do the following:




  • Iteratively calculate one image pixel $X$ using $X_{n+1}=X_n+X_0$ until the iteration exits due to iteration
    limit or distance estimate ($|X_n| >= 2$). I calculate and store all
    values of $X_n$, $A_n$, $B_n$, $C_n$ on the way.

  • Then for the next 3 pixels I use $Delta_n = A_ndelta_i+B_ndelta_i²+C_ndelta_i³$, where $delta_i = pixelspace index *{horizontalspace range over nrOfPixels}$ (the "horizontal step value"). Then supposedly the (estimated) value for the new pixel should be $Y_n = X_n + Delta_n$. This is where the speedup should come from.

  • Then I use $Y_n$ and decide whether to iterate further if $|Y_n| < 2$, or if $|Y_n| >= 2$ "step backwards" (calculate $Y_{n-1}$ like above), to see if $Y_n$ would have exited in an earlier iteration (until $|Y_{n-1}| < 2$).


This should make the 3 pixels "I cheat on" much cheaper to calculate (if this works I'd use 4x4 pixel chunks). Question is: Should this work in theory? It is not really working for me and I'm trying to find out what I'm doing wrong. "Regular" per-pixel Julia rendering is working ok for 16.16 and 8.24 fixed-point formats, so I suspect it's not calculation errors piling up...
I can post C++ code if that helps.



enter image description here







fractals perturbation-theory complex-dynamics






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Nov 18 at 14:04

























asked Nov 15 at 20:37









Bim

1012




1012












  • fractalforums.org/fractal-mathematics-and-new-theories/28/…
    – Adam
    Nov 17 at 20:38












  • How confident are you that your code for computing $A_n,B_n,C_n$ has no bugs?
    – Rahul
    Nov 18 at 14:22










  • mathr.co.uk/blog/…
    – Claude
    Nov 18 at 19:06


















  • fractalforums.org/fractal-mathematics-and-new-theories/28/…
    – Adam
    Nov 17 at 20:38












  • How confident are you that your code for computing $A_n,B_n,C_n$ has no bugs?
    – Rahul
    Nov 18 at 14:22










  • mathr.co.uk/blog/…
    – Claude
    Nov 18 at 19:06
















fractalforums.org/fractal-mathematics-and-new-theories/28/…
– Adam
Nov 17 at 20:38






fractalforums.org/fractal-mathematics-and-new-theories/28/…
– Adam
Nov 17 at 20:38














How confident are you that your code for computing $A_n,B_n,C_n$ has no bugs?
– Rahul
Nov 18 at 14:22




How confident are you that your code for computing $A_n,B_n,C_n$ has no bugs?
– Rahul
Nov 18 at 14:22












mathr.co.uk/blog/…
– Claude
Nov 18 at 19:06




mathr.co.uk/blog/…
– Claude
Nov 18 at 19:06










1 Answer
1






active

oldest

votes

















up vote
1
down vote













As far as I know, the perturbation techniques when applied to deep zooming have only been shown to work reliably for "Mandelbrot" iterations of the form $z := F(z) + c$ where $c$ is the pixel coordinates. I don't know if they can be expected to work for "Julia" iterations where it is the initial $z$ that is the pixel coordinates and $c$ is a constant.



Your first bullet point is fine, that's generally how it is done.



Your second bullet point is mostly ok, for Mandelbrot type iterations you have per pixel $delta = c_text{pixel} - c_text{ref}$, for Julia sets I suppose you replace $c$ with $z_0$. Re-deriving the update formulae for $A_n,B_n,C_n$ because they will be different to the Mandelbrot case:



$$begin{aligned}
Z_{n+1} &= Z_n^2 + C \
Z_{n+1}+z_{n+1} &:= (Z_n+z_n)^2 + C \
z_{n+1} &:= 2 Z_n z_n + z_n^2 \
delta &= z_0 \
z_n &= A_n delta + B_n delta^2 + C_n delta^3 \
end{aligned}$$

Substituting the last line into the third line and equating coefficients of $delta^k$ gives
$$begin{aligned}
A_0 &= 1 & A_{n+1} &= 2 Z_n A_n \
B_0 &= 0 & B_{n+1} &= 2 Z_n B_n + A_n^2 \
C_0 &= 0 & C_{n+1} &= 2 Z_n C_n + 2 A_n B_n\
end{aligned}$$

which you can see breaks down if ever $Z_n = 0$.



Your third bullet point is very problematic - the series is only approximate, and beyond a certain iteration count (dependent on location) it goes wild and all bets are off. You can use probe points on the boundary of the image (iterated in another way, and compared with the approximation) to detect when the series is starting to diverge from reality. This will typically be significantly before the pixel escapes to infinity.



One issue with fixed point is underflow and ensuing loss of precision. If $delta < frac{1}{10}$ then $delta^3 < frac{1}{1000} approx 2^{-10}$ so you have already lost almost half of your precision. On the other side, the coefficients $A_n, B_n, C_n$ get increasingly large, so you will probably overflow your limited range.



One possible solution is to rescale all your numbers, so instead of multiplying big $C_n$ with small $delta^3$ you take out a constant factor $K$ to make $epsilon = K delta$ have magnitude approximately equal to $1$. It becomes:



$$ frac{A_n}{K} times K delta + frac{B_n}{K^2} times K^2 delta^2 + frac{C_n}{K^3} times K^3 delta^3 = a_n epsilon + b_n epsilon^2 + c_n epsilon^3$$ with all the variables on the right hand side having magnitude near $1$, so no risk of overflow or underflow.



It's a matter of careful algebra to work out the update iterations for $a_n, b_n, c_n$, you will need to involve $K$ at certain points when multiplying scaled values, perhaps something like this: $$frac{X}{K} times_1 frac{Y}{K} = frac{Xtimes_1Y/_1K}{K} equiv x times_K y = xtimes_1y/_1K$$



I suggest instrumenting your program to tell you loudly when overflow occurs, underflow is harder to deal with I suppose.






share|cite|improve this answer























  • Thanks for the answer Claude. As I see it only the term $A_{n+1}=2Z_nA_n$ is different to the Mandelbrot case, the $+1$ is gone. Will try that out. Rescaling looks tricky and might not be possible speedwise (though I understand the necessity). Will look for under-/overflows through instrumentation.
    – Bim
    Nov 22 at 13:09













Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3000290%2fperturbation-theory-to-speed-up-julia-fractal-drawing%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













As far as I know, the perturbation techniques when applied to deep zooming have only been shown to work reliably for "Mandelbrot" iterations of the form $z := F(z) + c$ where $c$ is the pixel coordinates. I don't know if they can be expected to work for "Julia" iterations where it is the initial $z$ that is the pixel coordinates and $c$ is a constant.



Your first bullet point is fine, that's generally how it is done.



Your second bullet point is mostly ok, for Mandelbrot type iterations you have per pixel $delta = c_text{pixel} - c_text{ref}$, for Julia sets I suppose you replace $c$ with $z_0$. Re-deriving the update formulae for $A_n,B_n,C_n$ because they will be different to the Mandelbrot case:



$$begin{aligned}
Z_{n+1} &= Z_n^2 + C \
Z_{n+1}+z_{n+1} &:= (Z_n+z_n)^2 + C \
z_{n+1} &:= 2 Z_n z_n + z_n^2 \
delta &= z_0 \
z_n &= A_n delta + B_n delta^2 + C_n delta^3 \
end{aligned}$$

Substituting the last line into the third line and equating coefficients of $delta^k$ gives
$$begin{aligned}
A_0 &= 1 & A_{n+1} &= 2 Z_n A_n \
B_0 &= 0 & B_{n+1} &= 2 Z_n B_n + A_n^2 \
C_0 &= 0 & C_{n+1} &= 2 Z_n C_n + 2 A_n B_n\
end{aligned}$$

which you can see breaks down if ever $Z_n = 0$.



Your third bullet point is very problematic - the series is only approximate, and beyond a certain iteration count (dependent on location) it goes wild and all bets are off. You can use probe points on the boundary of the image (iterated in another way, and compared with the approximation) to detect when the series is starting to diverge from reality. This will typically be significantly before the pixel escapes to infinity.



One issue with fixed point is underflow and ensuing loss of precision. If $delta < frac{1}{10}$ then $delta^3 < frac{1}{1000} approx 2^{-10}$ so you have already lost almost half of your precision. On the other side, the coefficients $A_n, B_n, C_n$ get increasingly large, so you will probably overflow your limited range.



One possible solution is to rescale all your numbers, so instead of multiplying big $C_n$ with small $delta^3$ you take out a constant factor $K$ to make $epsilon = K delta$ have magnitude approximately equal to $1$. It becomes:



$$ frac{A_n}{K} times K delta + frac{B_n}{K^2} times K^2 delta^2 + frac{C_n}{K^3} times K^3 delta^3 = a_n epsilon + b_n epsilon^2 + c_n epsilon^3$$ with all the variables on the right hand side having magnitude near $1$, so no risk of overflow or underflow.



It's a matter of careful algebra to work out the update iterations for $a_n, b_n, c_n$, you will need to involve $K$ at certain points when multiplying scaled values, perhaps something like this: $$frac{X}{K} times_1 frac{Y}{K} = frac{Xtimes_1Y/_1K}{K} equiv x times_K y = xtimes_1y/_1K$$



I suggest instrumenting your program to tell you loudly when overflow occurs, underflow is harder to deal with I suppose.






share|cite|improve this answer























  • Thanks for the answer Claude. As I see it only the term $A_{n+1}=2Z_nA_n$ is different to the Mandelbrot case, the $+1$ is gone. Will try that out. Rescaling looks tricky and might not be possible speedwise (though I understand the necessity). Will look for under-/overflows through instrumentation.
    – Bim
    Nov 22 at 13:09

















up vote
1
down vote













As far as I know, the perturbation techniques when applied to deep zooming have only been shown to work reliably for "Mandelbrot" iterations of the form $z := F(z) + c$ where $c$ is the pixel coordinates. I don't know if they can be expected to work for "Julia" iterations where it is the initial $z$ that is the pixel coordinates and $c$ is a constant.



Your first bullet point is fine, that's generally how it is done.



Your second bullet point is mostly ok, for Mandelbrot type iterations you have per pixel $delta = c_text{pixel} - c_text{ref}$, for Julia sets I suppose you replace $c$ with $z_0$. Re-deriving the update formulae for $A_n,B_n,C_n$ because they will be different to the Mandelbrot case:



$$begin{aligned}
Z_{n+1} &= Z_n^2 + C \
Z_{n+1}+z_{n+1} &:= (Z_n+z_n)^2 + C \
z_{n+1} &:= 2 Z_n z_n + z_n^2 \
delta &= z_0 \
z_n &= A_n delta + B_n delta^2 + C_n delta^3 \
end{aligned}$$

Substituting the last line into the third line and equating coefficients of $delta^k$ gives
$$begin{aligned}
A_0 &= 1 & A_{n+1} &= 2 Z_n A_n \
B_0 &= 0 & B_{n+1} &= 2 Z_n B_n + A_n^2 \
C_0 &= 0 & C_{n+1} &= 2 Z_n C_n + 2 A_n B_n\
end{aligned}$$

which you can see breaks down if ever $Z_n = 0$.



Your third bullet point is very problematic - the series is only approximate, and beyond a certain iteration count (dependent on location) it goes wild and all bets are off. You can use probe points on the boundary of the image (iterated in another way, and compared with the approximation) to detect when the series is starting to diverge from reality. This will typically be significantly before the pixel escapes to infinity.



One issue with fixed point is underflow and ensuing loss of precision. If $delta < frac{1}{10}$ then $delta^3 < frac{1}{1000} approx 2^{-10}$ so you have already lost almost half of your precision. On the other side, the coefficients $A_n, B_n, C_n$ get increasingly large, so you will probably overflow your limited range.



One possible solution is to rescale all your numbers, so instead of multiplying big $C_n$ with small $delta^3$ you take out a constant factor $K$ to make $epsilon = K delta$ have magnitude approximately equal to $1$. It becomes:



$$ frac{A_n}{K} times K delta + frac{B_n}{K^2} times K^2 delta^2 + frac{C_n}{K^3} times K^3 delta^3 = a_n epsilon + b_n epsilon^2 + c_n epsilon^3$$ with all the variables on the right hand side having magnitude near $1$, so no risk of overflow or underflow.



It's a matter of careful algebra to work out the update iterations for $a_n, b_n, c_n$, you will need to involve $K$ at certain points when multiplying scaled values, perhaps something like this: $$frac{X}{K} times_1 frac{Y}{K} = frac{Xtimes_1Y/_1K}{K} equiv x times_K y = xtimes_1y/_1K$$



I suggest instrumenting your program to tell you loudly when overflow occurs, underflow is harder to deal with I suppose.






share|cite|improve this answer























  • Thanks for the answer Claude. As I see it only the term $A_{n+1}=2Z_nA_n$ is different to the Mandelbrot case, the $+1$ is gone. Will try that out. Rescaling looks tricky and might not be possible speedwise (though I understand the necessity). Will look for under-/overflows through instrumentation.
    – Bim
    Nov 22 at 13:09















up vote
1
down vote










up vote
1
down vote









As far as I know, the perturbation techniques when applied to deep zooming have only been shown to work reliably for "Mandelbrot" iterations of the form $z := F(z) + c$ where $c$ is the pixel coordinates. I don't know if they can be expected to work for "Julia" iterations where it is the initial $z$ that is the pixel coordinates and $c$ is a constant.



Your first bullet point is fine, that's generally how it is done.



Your second bullet point is mostly ok, for Mandelbrot type iterations you have per pixel $delta = c_text{pixel} - c_text{ref}$, for Julia sets I suppose you replace $c$ with $z_0$. Re-deriving the update formulae for $A_n,B_n,C_n$ because they will be different to the Mandelbrot case:



$$begin{aligned}
Z_{n+1} &= Z_n^2 + C \
Z_{n+1}+z_{n+1} &:= (Z_n+z_n)^2 + C \
z_{n+1} &:= 2 Z_n z_n + z_n^2 \
delta &= z_0 \
z_n &= A_n delta + B_n delta^2 + C_n delta^3 \
end{aligned}$$

Substituting the last line into the third line and equating coefficients of $delta^k$ gives
$$begin{aligned}
A_0 &= 1 & A_{n+1} &= 2 Z_n A_n \
B_0 &= 0 & B_{n+1} &= 2 Z_n B_n + A_n^2 \
C_0 &= 0 & C_{n+1} &= 2 Z_n C_n + 2 A_n B_n\
end{aligned}$$

which you can see breaks down if ever $Z_n = 0$.



Your third bullet point is very problematic - the series is only approximate, and beyond a certain iteration count (dependent on location) it goes wild and all bets are off. You can use probe points on the boundary of the image (iterated in another way, and compared with the approximation) to detect when the series is starting to diverge from reality. This will typically be significantly before the pixel escapes to infinity.



One issue with fixed point is underflow and ensuing loss of precision. If $delta < frac{1}{10}$ then $delta^3 < frac{1}{1000} approx 2^{-10}$ so you have already lost almost half of your precision. On the other side, the coefficients $A_n, B_n, C_n$ get increasingly large, so you will probably overflow your limited range.



One possible solution is to rescale all your numbers, so instead of multiplying big $C_n$ with small $delta^3$ you take out a constant factor $K$ to make $epsilon = K delta$ have magnitude approximately equal to $1$. It becomes:



$$ frac{A_n}{K} times K delta + frac{B_n}{K^2} times K^2 delta^2 + frac{C_n}{K^3} times K^3 delta^3 = a_n epsilon + b_n epsilon^2 + c_n epsilon^3$$ with all the variables on the right hand side having magnitude near $1$, so no risk of overflow or underflow.



It's a matter of careful algebra to work out the update iterations for $a_n, b_n, c_n$, you will need to involve $K$ at certain points when multiplying scaled values, perhaps something like this: $$frac{X}{K} times_1 frac{Y}{K} = frac{Xtimes_1Y/_1K}{K} equiv x times_K y = xtimes_1y/_1K$$



I suggest instrumenting your program to tell you loudly when overflow occurs, underflow is harder to deal with I suppose.






share|cite|improve this answer














As far as I know, the perturbation techniques when applied to deep zooming have only been shown to work reliably for "Mandelbrot" iterations of the form $z := F(z) + c$ where $c$ is the pixel coordinates. I don't know if they can be expected to work for "Julia" iterations where it is the initial $z$ that is the pixel coordinates and $c$ is a constant.



Your first bullet point is fine, that's generally how it is done.



Your second bullet point is mostly ok, for Mandelbrot type iterations you have per pixel $delta = c_text{pixel} - c_text{ref}$, for Julia sets I suppose you replace $c$ with $z_0$. Re-deriving the update formulae for $A_n,B_n,C_n$ because they will be different to the Mandelbrot case:



$$begin{aligned}
Z_{n+1} &= Z_n^2 + C \
Z_{n+1}+z_{n+1} &:= (Z_n+z_n)^2 + C \
z_{n+1} &:= 2 Z_n z_n + z_n^2 \
delta &= z_0 \
z_n &= A_n delta + B_n delta^2 + C_n delta^3 \
end{aligned}$$

Substituting the last line into the third line and equating coefficients of $delta^k$ gives
$$begin{aligned}
A_0 &= 1 & A_{n+1} &= 2 Z_n A_n \
B_0 &= 0 & B_{n+1} &= 2 Z_n B_n + A_n^2 \
C_0 &= 0 & C_{n+1} &= 2 Z_n C_n + 2 A_n B_n\
end{aligned}$$

which you can see breaks down if ever $Z_n = 0$.



Your third bullet point is very problematic - the series is only approximate, and beyond a certain iteration count (dependent on location) it goes wild and all bets are off. You can use probe points on the boundary of the image (iterated in another way, and compared with the approximation) to detect when the series is starting to diverge from reality. This will typically be significantly before the pixel escapes to infinity.



One issue with fixed point is underflow and ensuing loss of precision. If $delta < frac{1}{10}$ then $delta^3 < frac{1}{1000} approx 2^{-10}$ so you have already lost almost half of your precision. On the other side, the coefficients $A_n, B_n, C_n$ get increasingly large, so you will probably overflow your limited range.



One possible solution is to rescale all your numbers, so instead of multiplying big $C_n$ with small $delta^3$ you take out a constant factor $K$ to make $epsilon = K delta$ have magnitude approximately equal to $1$. It becomes:



$$ frac{A_n}{K} times K delta + frac{B_n}{K^2} times K^2 delta^2 + frac{C_n}{K^3} times K^3 delta^3 = a_n epsilon + b_n epsilon^2 + c_n epsilon^3$$ with all the variables on the right hand side having magnitude near $1$, so no risk of overflow or underflow.



It's a matter of careful algebra to work out the update iterations for $a_n, b_n, c_n$, you will need to involve $K$ at certain points when multiplying scaled values, perhaps something like this: $$frac{X}{K} times_1 frac{Y}{K} = frac{Xtimes_1Y/_1K}{K} equiv x times_K y = xtimes_1y/_1K$$



I suggest instrumenting your program to tell you loudly when overflow occurs, underflow is harder to deal with I suppose.







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited Nov 18 at 17:51

























answered Nov 18 at 15:44









Claude

2,418423




2,418423












  • Thanks for the answer Claude. As I see it only the term $A_{n+1}=2Z_nA_n$ is different to the Mandelbrot case, the $+1$ is gone. Will try that out. Rescaling looks tricky and might not be possible speedwise (though I understand the necessity). Will look for under-/overflows through instrumentation.
    – Bim
    Nov 22 at 13:09




















  • Thanks for the answer Claude. As I see it only the term $A_{n+1}=2Z_nA_n$ is different to the Mandelbrot case, the $+1$ is gone. Will try that out. Rescaling looks tricky and might not be possible speedwise (though I understand the necessity). Will look for under-/overflows through instrumentation.
    – Bim
    Nov 22 at 13:09


















Thanks for the answer Claude. As I see it only the term $A_{n+1}=2Z_nA_n$ is different to the Mandelbrot case, the $+1$ is gone. Will try that out. Rescaling looks tricky and might not be possible speedwise (though I understand the necessity). Will look for under-/overflows through instrumentation.
– Bim
Nov 22 at 13:09






Thanks for the answer Claude. As I see it only the term $A_{n+1}=2Z_nA_n$ is different to the Mandelbrot case, the $+1$ is gone. Will try that out. Rescaling looks tricky and might not be possible speedwise (though I understand the necessity). Will look for under-/overflows through instrumentation.
– Bim
Nov 22 at 13:09




















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3000290%2fperturbation-theory-to-speed-up-julia-fractal-drawing%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to send String Array data to Server using php in android

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Is anime1.com a legal site for watching anime?