How to format mathematical expressions?

Thank you @rgommers and @stefanv.

Indeed I should have written this

# Correct:
i = i + 1
submitted += 1
x = x*2 - 1
hypot2 = x*x + y*y
c = (a+b) * (a-b)
dfdx = sign*(-2*x + 2*y + 2)
result = 2*x**2 + 3*x**(2/3)
y = 4*x**2 + 2*x + 1
c_i1j = (1./n**2.
         *np.prod(0.5*(2.+abs(z_ij[i1, :])
                       + abs(z_ij) - abs(z_ij[i1, :]-z_ij)), axis=1))

I agree that it would be difficult to, not just code such a system, but also just write using these rules :sweat_smile:For this to work, it has to be simple. I guess I would be personally ok with what Black does without spaces around **,/,* and spaces otherwise. This would be simpler to use as you wouldn’t have to count and check who has the highest priority, etc.

i = i + 1
submitted += 1
x = x*2 - 1
hypot2 = x*x + y*y
c = (a + b)*(a - b)
dfdx = sign*(-2*x + 2*y + 2)
result = 2*x**2 + 3*x**(2/3)
y = 4*x**2 + 2*x + 1
c_i1j = (
    1.0
    /n**2.0
    *np.prod(
        0.5*(2.0 + abs(z_ij[i1, :]) + abs(z_ij) - abs(z_ij[i1, :] - z_ij)), axis=1
    )
)