Processing math: 100%
Ask Your Question
0

Solving a linear system of equations depending of a parameter

asked 1 year ago

endomorphisme59 gravatar image

updated 1 year ago

Hi,

Let a be a fixed parameter, and let (S):{xy+az=a ; a+ayz=1 ; x+y+z=2

I want to determine the solution of this system depending on the value of a. "By hand", I find that there is a unique solution if and only if a1;3, that there is no solution if a=3, and that there are infinitely many solutions if a=1. But when try with SageMath, I only get the case where a1;3...

var('x,y,z,a')
eq1 = x-y+a*z==a
eq2 = x+a*y-z==-1
eq3 = x+y+z==2
solve([eq1,eq2,eq3],x,y,z)

returns

[[x == (a - 1)/(a - 3), y == -1/(a - 3), z == (a - 4)/(a - 3)]]

How could I we do to solve properly this kind of problem with SageMath ?

Thanks in advance ;)

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 1 year ago

Emmanuel Charpentier gravatar image

updated 1 year ago

Well... Run :

reset()
var("x, y, z, a")
Eqs=[x-y+a*z==a, a+a*y-z==-1, x+y+z==2]
S1=solve(Eqs, (x, y, z))

Then :

sage: S1
[[x == (2*a - 1)/(a - 2), y == -(a^2 - a + 1)/(a^2 - a - 2), z == (a^2 - 4*a - 2)/(a^2 - a - 2)]]

(Note : your "resolution by hand" seems to be erroneous...)

Check :

sage: [[bool(u.subs(s)) for u in Eqs] for s in S1]
[[True, True, True]]

The problem arises from the presence of the parameter a in the denominator of the elements of the solution(s). Collect these denominators :

sage: Dens=set(flatten([[u.rhs().denominator() for u in s] for s in S1])) ; Dens
{a^2 - a - 2, a - 2}

We can now solve for a each of these denominators, giving us a list of problematic values :

sage: PV=set(flatten([u.solve(a) for u in Dens])) ; PV
{a == 2, a == -1}

We can substitute each of these problematic values for a in the system :

sage: {u: [v.subs(u) for v in Eqs] for u in PV}
{a == 2: [x - y + 2*z == 2, 2*y - z + 2 == -1, x + y + z == 2],
 a == -1: [x - y - z == -1, -y - z - 1 == -1, x + y + z == 2]}

and try to solve the substituted system in each case :

sage: {u: solve([v.subs(u) for v in Eqs], (x, y, z)) for u in PV}
{a == 2: [], a == -1: []}

In both cases, the system is impossible...

Neither Sympy, Giac, Fricas nor Mathematica seem to check the validity of the solution of this system ; it seems to be a general weakness of CASes, which do not check the conditions of existence of the expressions...

HTH,

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 1 year ago

Seen: 348 times

Last updated: Feb 01 '24