# Solving a system of equations using matrix form

Please bear with me as I am a beginner at Mathematica.

In the following system, all variables on the right hand side are known, except for w1, w2 and w3, for which we are trying to solve.

I am trying to solve this system in Mathematica, but I am not sure where to start. Also, in my real example, the system is composed of 10 equations instead of three: we are trying to solve for w1, w2 and w3 where FA = FB = FC = FD = .... = Fj.

Please let me know if the explanation is a bit confusing, and I will try to explain better! Thanks!

• You will have to post actual Mathematica code for readers to have much chance of offering assistance. Jun 19, 2014 at 19:53
• Sure, I will try doing that soon. Thanks. Jun 19, 2014 at 20:13
• Please note that the numerator results in scalar quantity (1x3.3x3.3.1=1x1). you can not equate vector quantity {FA,FB,FC} with scalar quantity. Jun 19, 2014 at 20:53
• @Algohi Yes you are right. There is a typo.. I will fix this Jun 19, 2014 at 21:01
• Just type out the equation(s) in plain ascii. I doubt anyone will want to enter, from scratch, what you've shown in an image. But readers might be willing to convert actual ascii equations, that can be cut and pasted, into proper Mathematica syntax. Jun 20, 2014 at 15:13

This will show you how to write the equations. Execute each step to see the result

sigma = Thread[Subscript[σ, {A, B, C}]]

(cov = Outer[Times, sigma, sigma] /.
Subscript[σ, x_] * Subscript[σ, y_] :>
Subscript[σ, x] * Subscript[σ, y]  *
Subscript[ρ, ToString[x] <> ToString[y]]) // MatrixForm

(m = Table[Subscript[β, i]^j,
{j, {A, B, C}}, {i, 3}].weights) //
MatrixForm

denom = (Total[
Table[Subscript[w, n]*Subscript[σ, n], {n, 3}]]^2 //
Expand) /.
Subscript[σ, x_] * Subscript[σ, y_] :>
Subscript[σ, x] * Subscript[σ, y]  *
Subscript[ρ, Sequence[x, y]]

f = Thread[Subscript[F, {A, B, C}]]

constraints = {Total[weights] == 1, Equal @@ (m.f)}

sol = Solve[Join[eqns, constraints], weights]


This last statement will not be solved in any reasonable amount of time (ever?). However, if the "known" values are given numeric values it might be doable.

sol = With[{***"assign numeric values here"***},
Solve[Join[eqns, constraints], weights]]

• I can't thank you enough for this! Jun 20, 2014 at 17:01
• Note with a little manipulation the denom quantity can be eliminated from the system. If you do that Solve will have an easier time of it. (Still highly unlikely to get a symbolic solution, but given all the symmetry it is worth a shot. ) Jun 20, 2014 at 17:54
• Actually all the known values have a numerical value assigned to them, so it is definitely solvable! Jun 20, 2014 at 19:36

This is simple way of writing the equations

Though no solution is found.

if you want to use the symbols as seen the image you can use the Mathematica Palettes which you can find at the main menu.