I've been trying to solve a system of three equations using the 4th as a parameter, but it hasn't been working. Mathematica just seems to run indefinitely even if I set a given value for the parameter.
First, I've needed to solve a few complicated linear equations using matrix methods.
This is the matrix that I've needed to invert and I've done so without too much hassle.
z =
{{-1, p, q, r, (1 - p - q - r), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{(1 - p - q - r), -1, p, q, r, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{(1 - s)*r, (1 - s)*(1 - p - q - r), -1, (1 - s)*p, (1 - s)*q, 0, 0, 0, s*p, s*r, s*(1 - p - q - r), 0, 0, 0, 0, 0},
{s*q, s*r, s*(1 - p - q - r), -1, s*p, (1 - s)*(1 - p - q - r), (1 - s)*q, (1 - s)*p, 0, 0, 0, 0, 0, 0, 0, 0},
{p, q, r, (1 - p - q - r), -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, p, 0, -1, r, q, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, r, 0, q, -1, (1 - p - q - r), 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, s*(1 - p - q - r), 0, s*r, s*p, -1, 0, 0, 0, 0, 0, (1 - s)*p, (1 - s)*q, (1 - s)*(1 - p - q - r)},
{0, 0, (1 - p - q - r), 0, 0, 0, 0, 0, -1, q, r, 0, 0, 0, 0, 0},
{0, 0, q, 0, 0, 0, 0, 0, r, -1, p, 0, 0, 0, 0, 0},
{0, 0, (1 - s)*p, 0, 0, 0, 0, 0, (1 - s)*q, (1 - s)*(1 - p - q - r), -1, s*p, s*r, s*(1 - p - q - r), 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (1 - p - q - r), -1, q, r, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, q, r, -1, p, 0, 0},
{0, 0, 0, 0, 0, 0, 0, s*(1 - p - q - r), 0, 0, (1 - s)*p, (1 - s)*q, (1 - s)*(1 - p - q - r), -1, s*p, s*r},
{0, 0, 0, 0, 0, 0, 0, r, 0, 0, 0, 0, 0, (1 - p - q - r), -1, q},
{0, 0, 0, 0, 0, 0, 0, p, 0, 0, 0, 0, 0, q, r, -1}}
Then to get the solutions to these linear equations I've set:
a =
(Inverse[z]).
({{0}, {0}, {-s*q}, {0}, {0}, {0}, {0}, {0}, {-p}, {-(1 - p - q - r)}, {-(1 - s)*r}, {0}, {0}, {0}, {0}, {0}})
b =
(Inverse[z]).
({{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {-s*q}, {-p}, {-(1 - p - q - r)}, {-(1 - s)*r}, {0}, {0}})
c = (
Inverse[z]).
({{0}, {0}, {0}, {0}, {0}, {0}, {0}, {-(1 - s)*r}, {0}, {0}, {0}, {0}, {0}, {-s*q}, {-p}, {-(1 - p - q - r)}})
Then I essentially want a fixed point of these equations with the top entry of a
equal to p
, the top entry of b
equal to q
and the top entry of c
equal to r
. If I could get this as a function of s
, that would be ideal, but if that's not possible, even numerical solutions for some s
would be useful.
Plugging in:
f=Part[a, 1],
g=Part[b, 1],
h=Part[c, 1],
NSolve[
{f - p == 0, g - q == 0, h - r == 0, s == 0.5},
{p, q, r}]
Just gives me a very long run time and seemingly no answer. Through other methods, I know that p = 0.355536, q = r = s - p = 0.5 - 0.355536
is one solution, but NSolve
doesn't seem to work here and just seems to run for a long time.
Is there another way to find the solutions to these equations in terms of s
or even numerically for given values of s
?
I would be grateful if anyone could help or suggest anything I might be able to do to solve complicated systems of equations like mine.