Summing Sequence with Combinatorics I am looking for help for two things.

proof of correctness (the tests have passed, but I do not now how to prove it correct)
Improvements on the Algorithm Efficiency.

The algorithm goes through 2 arrays arrays through permutations. The ordering is set up based on the array index, NOT the number inside the index. Noteably, if both parallel arrrays are set up diffrent, the algorithm should run fine.The algorithm then adds the function to the sum, which estimates computes the series.
Code is below.

def f(x:float, y:float, a:float)-&gt;float:
    &quot;&quot;&quot;
    param x:float, x coordinate 
    param y:flaot, y coordinate 
    param a:float, paramter of the curve 
    &quot;&quot;&quot;
    return x + (y * a)

def main():
    &quot;&quot;&quot;
    algorithm: 
    Suppouse arrays are orderd by thier index and NOT the element inside 
    Go through an ordering which meets that (one ordering is enough) 
    add on the function at that point to the sequence 
    &quot;&quot;&quot;
    x = [1.0, 2.0, 3.0]
    y = [2.0, 3.0, 4.0]
    a = 2.0 
    seq = [0.0] * len(x)
    for row in range(0, len(x) + 1):
        for col in range(0, len(x) + 1):
            for at in range(row, col):
                seq[at] = seq[at] + f(x[at], y[at], a)
    print(seq)
    
if __name__ == &quot;__main__&quot;:
    main()
Disclaimer: Not a Code Reviewer
Just some comments:

Looks not bad at all;

First thing first, read through PEP8 if you like – I should also do that myself ( ˆ_ˆ )

Name things just a bit more descriptive, I understand that math people code like that and use single variable naming a lot;

Comment concise (one perfect scenario – which does not exist – would be the understandability of the code without any comment);

Use unittest if you like;

Turn on your IDE's spell checking;

Not sure about what we are doing overall, but my guess is that we might be able to start the second loop from the row + 1:


def get_linear_calc(x: float, y: float, coeff: float) -&gt; float:
    &quot;&quot;&quot;
    param x:float, x coordinate
    param y:flaot, y coordinate
    param coeff:float, parameter of the curve
    &quot;&quot;&quot;
    return x + (y * coeff)


def get_ordered_sequence(x, y, coeff):
    &quot;&quot;&quot;
    algorithm:
    Suppose arrays are ordered by their index and NOT the element inside
    Go through an ordering which meets that (one ordering is enough)
    add on the function curr that point to the sequence
    &quot;&quot;&quot;
    seq = [0.0] * len(x)
    for row in range(len(x) + 1):
        for col in range(row + 1, len(x) + 1):
            for curr in range(row, col):
                seq[curr] += get_linear_calc(x[curr], y[curr], coeff)
    return seq


if __name__ == &quot;__main__&quot;:
    x = (1.0, 2.0, 3.0, 2.0)
    y = (2.0, 3.0, 4.0, 1.0)
    coeff = 2.0
    print(get_ordered_sequence(x, y, coeff))

PS: I don't name things well, ignore my naming.