# Does using subscripted variables decrease the performance of Mathematica?

I tried integrating two equation with the same structure, the first equation fails to evaluate completely - the answer is still in terms of integration. The second integration evaluated fine. The only difference between these two equation is that the first equation uses subscripts in the variable names. Does that mean Mathematica doesn't handle subscripted variables well?

The first equation:

Integrate[(Subscript[c, 1] Subscript[x, 1] +
Subscript[c, 2] Subscript[x, 2]) Sqrt[(Subscript[c, 1] Subscript[y, 1] +
Subscript[c, 2] Subscript[y, 2]) (Subscript[c, 1] Subscript[z, 1] +
Subscript[c, 2] Subscript[z, 2])], Subscript[c, 1], Subscript[c, 2]]


The second equation:

Integrate[(c1 x1 + c2 x2) Sqrt[(c1 y1 + c2 y2) (c1 z1 + c2 z2)], c1, c2]

• I believe it is generally recommended to avoid linear syntax in your coding. On a large scale it can theoretically slow things down, and on a smaller scale you can occasionally run into trouble in other places. I don't have any examples ready, but again it's recommended. – user6014 Oct 6 '16 at 3:05
• Looks like a bug to me. – wolfies Dec 12 '16 at 14:47
• As per the other comment its going to land you in a world of hurt trying to perfectly match notation in Mathematica. You are better off using text group above the code that executes to explain your code within which you can have something neat, formatted or merely pasted as an image from another application. – Ramble Dec 12 '16 at 17:29
• Symbolize from the Notations package is often maligned around here but IMO is useful in many cases such as this – Mike Honeychurch Dec 12 '16 at 23:57
• Note that this issue has nothing to to with subscripts -- it also fails to integrate over both variables if you use regular old downvalues: Integrate[(c[1] x[1] + c[2] x[2]) Sqrt[(c[1] y[1] + c[2] y[2]) (c[1] z[1] + c[2] z[2])], c[1], c[2]]. Definitely a problem with Integrate. People always want to pick on poor old subscripts! – Simon Rochester Dec 13 '16 at 6:11

Subscripts are generally more trouble than they are worth and cannot be used as variables. You can use Format to display variables as if subscripted.

Format[c1] := Subscript["c", 1]
(* string used to avoid problem if symbol c has assigned value *)
Format[c2] := Subscript["c", 2]
Format[x1] := Subscript["x", 1]
Format[x2] := Subscript["x", 2]
Format[y1] := Subscript["y", 1]
Format[y2] := Subscript["y", 2]
Format[z1] := Subscript["z", 1]
Format[z2] := Subscript["z", 2]

expr = (c1 x1 + c2 x2) Sqrt[(c1 y1 + c2 y2) (c1 z1 + c2 z2)]


int=Integrate[expr, c1, c2]


The InputForm does not have the subscripts

int // InputForm

(Sqrt[(c1*y1 + c2*y2)*(c1*z1 + c2*z2)]*
((-3*c1^4*(y2*z1 - y1*z2)^2*(x2*y2*z1 +
x2*y1*z2 - 2*x1*y2*z2))/
(Sqrt[c1*y1 + c2*y2]*Sqrt[c1*z1 + c2*z2]) -
(8*Sqrt[y2]*Sqrt[z2]*(-2*c1*c2^2*y1*y2^2*z1*
z2^2*(10*x2*y1*z1 + x1*y2*z1 +
x1*y1*z2) - 2*c1^2*c2*y1^2*y2*z1^2*z2*
(x2*y2*z1 + x2*y1*z2 + 10*x1*y2*z2) +
c2^3*y2^2*z2^2*(-6*x2*y1*z1*
(y2*z1 + y1*z2) + x1*(3*y2^2*z1^2 -
2*y1*y2*z1*z2 + 3*y1^2*z2^2)) +
c1^3*y1^2*z1^2*(-6*x1*y2*z2*
(y2*z1 + y1*z2) + x2*(3*y2^2*z1^2 -
2*y1*y2*z1*z2 + 3*y1^2*z2^2))))/
(y1^2*z1^2) + (12*c2^4*y2^(5/2)*z2^(5/2)*
(y2*z1 - y1*z2)^2*(-2*x2*y1*z1 +
x1*y2*z1 + x1*y1*z2)*
Log[2*c1*y1*z1 + c2*y2*z1 + c2*y1*z2 +
2*Sqrt[y1]*Sqrt[c1*y1 + c2*y2]*Sqrt[z1]*
Sqrt[c1*z1 + c2*z2]])/
(y1^(5/2)*Sqrt[c1*y1 + c2*y2]*z1^(5/2)*
Sqrt[c1*z1 + c2*z2]) +
(12*c1^4*(y2*z1 - y1*z2)^2*(x2*y2*z1 +
x2*y1*z2 - 2*x1*y2*z2)*
Log[c1*y2*z1 + c1*y1*z2 + 2*c2*y2*z2 +
2*Sqrt[y2]*Sqrt[c1*y1 + c2*y2]*Sqrt[z2]*
Sqrt[c1*z1 + c2*z2]])/
(Sqrt[c1*y1 + c2*y2]*Sqrt[c1*z1 + c2*z2])))/
(768*y2^(5/2)*z2^(5/2))