# Solve multiple equations and getting solutions [duplicate]

This is my first post here so I'm not really sure how all of this works, but I'll try my best to explain my problem. I'm supposed to solve the equation system

ax + y + az = 2
x + ay + z = 2
x + az = 1


and then answer "for which values on a does the equation system only have one solution? For which values on a do we have an infinite amount of solutions, and what value on a lacks solutions."

I understand that I'm supposed to use solve, but I'm not exactly sure how. My current code is

Solve[{a*x + y + a*z == 2, x + a*y + z == 2, x + a*z == 1}, x, y, z]


But it just throws an error with z, so I understand that the condition at the end must be changed, but I don't know to what.

• You are almost there. the second argument of Solve must be a list. That is, {x,y,z}, rather than x,y,z.This will give you the solution. I propose that you take a look at the documentation. To answer about the infinite number of solutions check Menu/WolframDocumentation/Det and apply the corresponding theorem. – Alexei Boulbitch Nov 3 '18 at 16:21

Try this:

Solve[{a*x + y + a*z == 2, x + a*y + z == 2, x + a*z == 1}, {x, y, z}]


The solution is:

(* {{x -> -(1/(-1 - a)), y -> 2/(1 + a), z -> 1/(1 + a)}} *)

• Ah, I forgot the curly brackets around the second arguments, just as you and Alexei above pointed out! Regarding "the for which values on a does the equation system only have on solution? For which values on a doe we have an infinite amount of solutions, and what value on a lacks solutions" part, how should I do this? – Griezy Nov 3 '18 at 16:30
• @Griezy: Since you have a linear system of three equations, you should just analyze the coefficient matrix, C={{a,1,a},{1,a,1},{1,0,a}} in your example. For real solution, a should not be equal to 1 nor -1, in which case you will end up with indeterminacy. for all other values of coefficients there is a real solution. – Tugrul Temel Nov 3 '18 at 16:39
• So as long as a is not equal to 1 or -1, there's an infinate amount of solutions? For which values does a only have one solution then? And for what value of do we not have any solutions? – Griezy Nov 3 '18 at 16:52
• @Griezy: Yes, you right. For your second question, If I understand you correctly, you want a solution for a. If this is the case, you should just solve the solution for a in terms of x,y,z. (1+a)=(-1/x)=(2/y)=(1/z). But I do not know what you want to achieve with this exercise. If you tell your goal then it can be answered. – Tugrul Temel Nov 3 '18 at 17:02
• My goal is to after solving the equation system: solve for which values on a has the equation system only have on solution? For which values on a do we have an infinite amount of solutions(solved), and what value on a lacks solutions – Griezy Nov 3 '18 at 17:06

I think you will find utility in Reduce.

eqs = {a*x + y + a*z == 2, x + a*y + z == 2, x + a*z == 1};

Reduce[eqs, {x, y, z}, Backsubstitution -> True]

(a == 1 && y == 1 && z == 1 - x) ||
((-1 + a) (1 + a) != 0 && x == 1/(1 + a) && y == 2/(1 + a) && z == 1/(1 + a))


Using Reduce again for further information on the condition of the second solution:

Reduce[(-1 + a) (1 + a) == 0]    (* note != changed to == *)

a == -1 || a == 1


This gives no solution for $$a = -1$$. ($$a = 1$$ has a separate solution listed first.)

Checking it:

Reduce[eqs /. a -> -1]

False


Merely looking at the form of the second solution with (1 + a) as the denominator of each x,y,z should lead us to consider the case of $$a = 0$$:

Reduce[eqs /. a -> 0]

y == 2 && z == 1 && x == 1