# How to declare more than one function in a list?

My code:

eq = {x + y - z == -1, x^2 + y^2 - z == 3};
sol1 = Eliminate[eq, z]
sol2 = Solve[sol1, y]


At this point I would like to define to functions $y(x)$ to get theri domain with FunctionDomain. But I get an error typing this line:

{a1[x_], a2[x_]} :=  {y /. sol2}


The problem is that the two lists are not of the same type. How can I explain that the right term is a function in x?

• Try {a1[x_], a2[x_]} := Evaluate[y /. sol2]. You can check the definitions with ?a1 and ?a2. Mar 25, 2018 at 14:12
• The major issue was that SetDelayed has the attribute HoldAll. In particular, {a1[x_], a2[x_]} := y /. sol2 cannot see that the right hand side is also a list of length 2. This is what gets remedied by Evaluate. Mar 25, 2018 at 14:29
• @HenrikSchumacher It works!! Thank you! Mar 25, 2018 at 14:38
• You're welcome! Mar 25, 2018 at 14:45

It is not necessary to define functions to find the domain

eq = {x + y - z == -1, x^2 + y^2 - z == 3};

sol = y /. Solve[eq, y, {z}]


(* {1/2 (1 - Sqrt[17 + 4 x - 4 x^2]), 1/2 (1 + Sqrt[17 + 4 x - 4 x^2])} *)

They have a common domain as shown with Union

fd = Union[FunctionDomain[#, x] & /@ sol]

(* {1/2 (1 - 3 Sqrt[2]) <= x <= 1/2 (1 + 3 Sqrt[2])} *)

Plot[Evaluate@Reverse@sol, {x, fd[[1, 1]], fd[[1, -1]]},
Frame -> True, PlotLegends -> Placed["Expressions", {.62, .6}]]


You could also just plot sol rather than Evaluate@Reverse@sol but the PlotLegends would then be upside down compared with their curves.