• September 19, 2021, 12:39:10 AM

Author Topic:  Series Approximation for other powers  (Read 206 times)

0 Members and 1 Guest are viewing this topic.

Offline superheal

  • Fractal Friar
  • *
  • Posts: 111
Series Approximation for other powers
« on: September 07, 2021, 09:43:10 PM »
Has anyone managed to create the SA formulas for other mandelbrot powers like 3 or 4?
Are there any formulas for the burning-ship variants?

Linkback: https://fractalforums.org/index.php?topic=4398.0

Offline claude

  • 3f
  • ******
  • Posts: 1991
    • mathr.co.uk
Re: Series Approximation for other powers
« Reply #1 on: September 07, 2021, 10:08:11 PM »
KF has 3 terms for arbitrary power Mandelbrot: https://code.mathr.co.uk/kalles-fraktaler-2/blob/7adcf8dafd007f8da0c164fb020910f4fc37053c:/fraktal_sft/floatexp_approximation.cpp#l363
This is from before I took over.

KF has some series for Burning Ship (two bivariate real series) but it only skips one period (at most), because of the folding...

Offline superheal

  • Fractal Friar
  • *
  • Posts: 111
Re: Series Approximation for other powers
« Reply #2 on: September 07, 2021, 11:25:43 PM »
Is there any general formula to get more terms, for power N?

Offline superheal

  • Fractal Friar
  • *
  • Posts: 111
Re: Series Approximation for other powers
« Reply #3 on: September 08, 2021, 11:24:39 AM »
Also another question, how do you initialize A0, B0, C0?
A0 =1, B0 = 0, C0 = 0?

Do we still need to calculate the same powers of Delta for all powers P?
An*D + Bn*D^2 + Cn*D^3

Offline claude

  • 3f
  • ******
  • Posts: 1991
    • mathr.co.uk
Re: Series Approximation for other powers
« Reply #4 on: September 08, 2021, 12:14:21 PM »
Maybe you can work out some patterns using a computer algebra system, for example Sage (based on Python) or Maxima (based on Common Lisp).  You can use Sage online without installing anything:
https://sagecell.sagemath.org/?z=eJxtkEEKwjAQRfeCd_h0NaOxWBeCgitv4UIpMWlDtYZURT29U1tpi2YTZvh58yb2EuDhSoS0zAwtFJa8Ho8gx5JWeDE2eO09ptBN2wdXXslyU2W0VdgpfKNkaVtnpSmXtGbCqSPMsXn4tDwSx5U7-5OzT-I-MmurfE66RlW3M-GeBorSQySw6hqoYMYEel_AinjRiScKK8aAl8-_wKQB9lw_M_pGJjhT1Quv2kf_-O3HdCN-7VS03kTqMzHWF2Ot085IUpR5YMdvqDBgIA==&lang=sage&interacts=eJyLjgUAARUAuQ==
Code: [Select]
for p in range(2, 6):
    f(c, z) = z^p + c
    print(f)
    g(C, Z, c, z) = (f(C + c, Z + z) - f(C, Z)).expand().simplify()
    print(g)
    h0(c) = sum( var("a_" + str(k)) * c^k for k in range(1, 9) )
    print(h0)
    h1(c) = g(C, Z, c, h0(c)).expand().series(c, 9)
    for k in range(1, 9):
        print(var("a_" + str(k)),":=",h1(c).coefficient(c^k))
    print()
Code: [Select]
(c, z) |--> z^2 + c
(C, Z, c, z) |--> 2*Z*z + z^2 + c
c |--> a_8*c^8 + a_7*c^7 + a_6*c^6 + a_5*c^5 + a_4*c^4 + a_3*c^3 + a_2*c^2 + a_1*c
a_1 := 2*Z*a_1 + 1
a_2 := a_1^2 + 2*Z*a_2
a_3 := 2*a_1*a_2 + 2*Z*a_3
a_4 := a_2^2 + 2*a_1*a_3 + 2*Z*a_4
a_5 := 2*a_2*a_3 + 2*a_1*a_4 + 2*Z*a_5
a_6 := a_3^2 + 2*a_2*a_4 + 2*a_1*a_5 + 2*Z*a_6
a_7 := 2*a_3*a_4 + 2*a_2*a_5 + 2*a_1*a_6 + 2*Z*a_7
a_8 := a_4^2 + 2*a_3*a_5 + 2*a_2*a_6 + 2*a_1*a_7 + 2*Z*a_8

(c, z) |--> z^3 + c
(C, Z, c, z) |--> 3*Z^2*z + 3*Z*z^2 + z^3 + c
c |--> a_8*c^8 + a_7*c^7 + a_6*c^6 + a_5*c^5 + a_4*c^4 + a_3*c^3 + a_2*c^2 + a_1*c
a_1 := 3*Z^2*a_1 + 1
a_2 := 3*Z*a_1^2 + 3*Z^2*a_2
a_3 := a_1^3 + 6*Z*a_1*a_2 + 3*Z^2*a_3
a_4 := 3*a_1^2*a_2 + 3*Z*a_2^2 + 6*Z*a_1*a_3 + 3*Z^2*a_4
a_5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a_7 := 10*a_1^3*a_2^2 + 20*Z*a_1*a_2^3 + 5*a_1^4*a_3 + 60*Z*a_1^2*a_2*a_3 + 30*Z^2*a_2^2*a_3 + 30*Z^2*a_1*a_3^2 + 20*Z*a_1^3*a_4 + 60*Z^2*a_1*a_2*a_4 + 20*Z^3*a_3*a_4 + 30*Z^2*a_1^2*a_5 + 20*Z^3*a_2*a_5 + 20*Z^3*a_1*a_6 + 5*Z^4*a_7
a_8 := 10*a_1^2*a_2^3 + 5*Z*a_2^4 + 20*a_1^3*a_2*a_3 + 60*Z*a_1*a_2^2*a_3 + 30*Z*a_1^2*a_3^2 + 30*Z^2*a_2*a_3^2 + 5*a_1^4*a_4 + 60*Z*a_1^2*a_2*a_4 + 30*Z^2*a_2^2*a_4 + 60*Z^2*a_1*a_3*a_4 + 10*Z^3*a_4^2 + 20*Z*a_1^3*a_5 + 60*Z^2*a_1*a_2*a_5 + 20*Z^3*a_3*a_5 + 30*Z^2*a_1^2*a_6 + 20*Z^3*a_2*a_6 + 20*Z^3*a_1*a_7 + 5*Z^4*a_8

Initialisation is as you say, first coefficient (of c^1) is 1, remainder are 0.  Maybe some of the coefficients will always be zero in practice, but looking at the output from the Sage code a_2 always mentions a_1 which is non-zero in general so I think they'll all be non-zero in general?  Hard to be sure without trying it out...  This is different from (parts of) the bivariate series used in nanomb, iirc.

Offline claude

  • 3f
  • ******
  • Posts: 1991
    • mathr.co.uk
Re: Series Approximation for other powers
« Reply #5 on: September 08, 2021, 01:50:47 PM »
Fairly sure it works out as (Python/Sage syntax on rhs):
Code: [Select]
a(k)_{n+1} := (1 if k == 1 else 0) + sum([binomial(p, t) * Z^(p-t) * sum([Permutations(qs).cardinality() * product([a(q) for q in qs]) for qs in Partitions(k, length=t).list()]) for t in range(1, k + 1)])
SageCell link

The first column should be all 0 if the one-liner is correct.

Offline superheal

  • Fractal Friar
  • *
  • Posts: 111
Re: Series Approximation for other powers
« Reply #6 on: September 08, 2021, 04:18:02 PM »
Well, taking this as well:
int P = m_nPower;
 366                                 complex<floatexp> X(xr, xi), A(APr[0], APi[0]), B(APr[1], APi[1]), C(APr[2], APi[2]);
 367                                 complex<floatexp> An = P * A * (X^(P-1)) + 1;
 368                                 complex<floatexp> Bn = P * B * (X^(P-1)) + ((P*(P-1))/2) * (A^2) * (X^(P-2));
 369                                 complex<floatexp> Cn = P * C * (X^(P-1)) + (P*(P-1)) * A * B * (X^(P-2)) + ((P*(P-2)*(P-2))/6) * (A^3) * (X^(P-3));

The C term for 3rd power is Cn = 3 * C* X^2 + 6 *A*B * X

if I compare to a_3 := a_1^3 + 6*Z*a_1*a_2 + 3*Z^2*a_3  we have an extra a_1^3 term.
If the  ((P*(P-2)*(P-2))/6) was a double division then this would yield 0.5 * a_1^3

What do you think, should I use a double division?

Is the original code in KF wrong?

Offline claude

  • 3f
  • ******
  • Posts: 1991
    • mathr.co.uk
Re: Series Approximation for other powers
« Reply #7 on: September 08, 2021, 04:51:25 PM »
Is the original code in KF wrong?
good catch, I think it is a typo and should be P*(P-1)*(P-2)/6 (where int vs double division wouldn't make a difference)

Offline superheal

  • Fractal Friar
  • *
  • Posts: 111
Re: Series Approximation for other powers
« Reply #8 on: September 12, 2021, 08:21:31 PM »
Thanks for your help, it worked fine!
I know I ask a lot, but I am not that of a math guru.
Is it any generic Sum formula like the one you have here:
https://mathr.co.uk/blog/2016-03-06_simpler_series_approximation.html
for any power?
I coded up to 5 terms for the 3rd and 4th power but I wanted to use the generic sum for higher terms.

Offline claude

  • 3f
  • ******
  • Posts: 1991
    • mathr.co.uk
Re: Series Approximation for other powers
« Reply #9 on: September 13, 2021, 01:16:26 PM »
Is it any generic Sum formula like the one you have here:
I posted it here earlier: https://fractalforums.org/programming/11/series-approximation-for-other-powers/4398/msg30433#msg30433
A bit of blog about it: https://mathr.co.uk/blog/2021-09-08_generalized_series_approximation.html last couple of paragraphs deal with how to implement it.
It's a bit complicated with the partitions and permutations, so making lookup tables at runtime might be necessary for efficiency.


xx
How to Get More Than 3 Series Approximation Terms?

Started by Byte11 on Fractal Mathematics And New Theories

16 Replies
1474 Views
Last post December 21, 2017, 09:09:44 AM
by knighty
xx
Series approximation for the Burning Ship

Started by claude on Fractal Mathematics And New Theories

0 Replies
333 Views
Last post September 27, 2018, 06:05:07 PM
by claude
xx
How to implement Series Approximation in GLSL?

Started by Mr Rebooted on Programming

2 Replies
312 Views
Last post November 23, 2020, 10:45:25 PM
by sjhalayka
clip
bad analytic DE/slopes when series approximation is disabled

Started by claude on Kalles Fraktaler

4 Replies
204 Views
Last post June 23, 2020, 07:44:35 AM
by claude
xx
Keyframe interpolation, series approximation and periods.

Started by unassigned on Programming

1 Replies
234 Views
Last post November 09, 2020, 06:27:53 PM
by claude