Off[General::spell1]; Off[General::spell];

(T= (1/2)*m*(x'[t]^2+y'[t]^2);
V= (1/2)*Federk*(((Sqrt[x[t]^2 + (y[t] - (1/2))^2]) - 
                        l)^2 + (l - (Sqrt[(1 - x[t])^2 + (y[t] - (1/2))^2]))^2);
L = T - V;)

(Gleichung1=D[D[L,x'[t]],t]==D[L, x[t]]//Simplify;
Gleichung2=D[D[L,y'[t]],t]==D[L, y[t]]//Simplify;)

Lsgn=Solve[{Gleichung1, Gleichung2},{x''[t],y''[t]}]//Flatten//Simplify;

x[t] = x; y[t] = y;x'[t]=xp;y'[t]=yp;

(forcex=Lsgn[[1, 2]] // Expand // Simplify // 
              InputForm;
\(StringReplace[
            ToString[
              forcex], {"x^2" -> "x*x", "y^2" -> "y*y"
, "(1 - 2*y)^2" -> "(1 - 2*y)*(1 - 2*y)"
, "Federk" -> "D", "Sqrt[" -> "Math.sqrt(", "]" -> ")"}]\))

(forcey=Lsgn[[2, 2]] // Expand // Simplify // 
              InputForm;
\(StringReplace[
            ToString[
              forcey], {"x^2" -> "x*x", "y^2" -> "y*y"
, "(1 - 2*y)^2" -> "(1 - 2*y)*(1 - 2*y)"
, "Federk" -> "D", "Sqrt[" -> "Math.sqrt(", "]" -> ")"}]\))

(\(Energy = \(\(T + V // Simplify\) // Expand\) // 
            InputForm; 
StringReplace[
          ToString[
            Energy], {"l^2" -> "l*l", "xp^2" -> "xp*xp", "yp^2" -> "yp*yp"
, "x^2" -> "x*x", "y^2" -> "y*y", "(-1 + x)^2" -> "(-1 + x)*(-1 + x)"
, "(-1/2 + y)^2" -> "(-1/2 + y)*(-1/2 + y)"
, "Federk" -> "D", "Sqrt[" -> "Math.sqrt(", "]" -> ")"}]\))