3
$\begingroup$

Suppose I want to solve an equation for the matrix elements of $\bar{W}$: $$\alpha W_{ba}+\beta W_{bb}=x; \alpha W_{aa}+\beta W_{ab}=y$$

Using the syntax Subscript[W, ij] for my matrix element (on the $i$th row and $j$ th column), I get the following message:

Set::write: Tag Times in 2 x is Protected.

Is is possible at all to write such double subscript in Mathematica?

$\endgroup$
  • 1
    $\begingroup$ Are you sure the error you're getting comes from the use of a double subscript? Subscript objects normally work fine inside of Solve; for an example, try Solve[{\[Alpha] Subscript[W, aa] + \[Beta] Subscript[W, ab] == y}, {Subscript[W, ab]}]. It would help to see your code so that we can more easily track down your error. $\endgroup$ – Michael Seifert Mar 13 '17 at 17:31
  • $\begingroup$ You are right. My error came from a missing syntax in Solve. $\endgroup$ – E Be Mar 13 '17 at 17:36
4
$\begingroup$

Use Equal rather than Set in an equation.

I recommend that you use Format to display the output in subscripted form without subsequently having to enter subscripts.

Format[W[a_, b_]] := Subscript[W, StringJoin @@ ToString /@ {a, b}]

Solve[2 x == W[a, a], x][[1]]

enter image description here

|improve this answer|||||
$\endgroup$
4
$\begingroup$

https://reference.wolfram.com/language/ref/Subscript.html

Array[Subscript[a, #1, #2] &, {3, 3}] // MatrixForm
|improve this answer|||||
$\endgroup$
  • $\begingroup$ I am trying to solve the following simple equation: Solve[2 x = Subscript[W, a, a], x] and get the error message Set::write: Tag Times in 2 x is Protected. Solve::naqs: Subscript[W, a,a] is not a quantified system of equations and inequalities.. why is that? $\endgroup$ – E Be Mar 13 '17 at 12:43

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.