# Customized FortranForm output

Let's take the following example

V = (-G*Mn)/Sqrt[x^2 + y^2 + z^2 + cn^2];
Vx = D[V, x];
FortranForm[Vx]


The result is (G*Mn*x)/(cn**2 + x**2 + y**2 + z**2)**1.5.

My questions is the following:

1. How can I replace x, y, z with x(1), x(2), x(3) respectively?

2. How can I get rid of the spaces between the plus signs?

V = (-G*Mn)/Sqrt[x^2 + y^2 + z^2 + cn^2];

• Many thanks! However according to my post the replacement rule should be: {x -> x[1], y -> x[2], z -> x[3]}. – Vaggelis_Z Jun 30 '15 at 13:23