0
$\begingroup$

When I have code like

b = Array[Subscript[be, #] &, {3, 1}]
b = b /. {Subscript[be, k_] :> Subscript[-be, k] /; k > 1}

I am noticing that Mathematica does not accept the new element as a signed number, i.e., negative be but rather as a string object. Is there a way to fix this?

For example, the following code generates an error then when I am solving for Subscript[be, 2] but not when I solve for Subscript[-be, 2] which tells me that Mathematica looks at this more like a string than a number.

(m = Array[Subscript[a, ##] &, {3, 3}]) // MatrixForm
m = m /. Subscript[a, i_, j_] :> Subscript[a, j, i] /; j < i
b = Array[Subscript[be, #] &, {3, 1}]
b = b /. {Subscript[be, 1] -> 1, 
   Subscript[be, k_] :> Subscript[(-1)*be, k] /; k > 1}
p = Transpose[b].m.b
Solve[p == 0, Subscript[be, 2], Complexes]
$\endgroup$
  • 2
    $\begingroup$ If you are going to be spending a lot of time with matrices in Mathematica, you should probably stop using the Subscript function. This is mostly a formatting function (like MatrixForm) and will cause no end of grief. $\endgroup$ – bill s Feb 28 '15 at 17:40
  • $\begingroup$ Thanks @bills I agree it is painful. I solved it and wrote an answer. $\endgroup$ – Hirek Feb 28 '15 at 18:03
  • 4
    $\begingroup$ I think what bills is trying to say is that instead of using Subscript[a, ##] you should use a[##]. It doesn't look as nice, but subscripts are really annoying to use in Mathematica, and should ideally be avoided. $\endgroup$ – DumpsterDoofus Feb 28 '15 at 18:20
  • 2
    $\begingroup$ The most most part I agree with bill, but why are you using Subscript[-be, k] rather than -Subscript[be, k]? $\endgroup$ – Mr.Wizard Feb 28 '15 at 18:28
  • $\begingroup$ Yeah, that's what I wrote in my answer. I am using the output to study the structure of the problem so I need it to be as humanly legible as possible. $\endgroup$ – Hirek Feb 28 '15 at 18:40
1
$\begingroup$

A way to solve this is making the following change the fourth line into

b = b /. {Subscript[be, 1] -> 1, 
   Subscript[be, k_] :> (-1)*Subscript[be, k] /; k > 1}

where we have taken the negative one out the Subscript function. This came from the kind comment by @bills that Subscript is mostly a formatting function whose output can become the numerical object.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.