I think the best way would be to parallelize the following part of your code with Jax (it can help you even if function1 is not a pure function)
constant_value * (array1[j,k] * function1(i - j))
Pseudo code if it is a pure function:
> Pre-calculate each value for all i and j combinations
> use Jax for parallel multiplication of the above part of the code
> generate the value of array2[i,k] in the similar way with these precomputed values
If it is not a pure function then you can refer the following link to see how to you can parallelize it. Refer this link