How can I make it solve this (easy) system of equations?
Solve[y==x^2 && a==x, a]
The system of equations is solved when a==Sqrt[y], but Mathematics tells me the solution is empty-set {}. I get the same results using SolveAlways. What am I doing wrong?
Per refguide page for Solve:
“Solve gives generic solutions only. Solutions that are valid only when continuous parameters satisfy equations are removed. Other solutions that are only conditionally valid are expressed as ConditionalExpression objects.”
This system imposes nongeneric conditions, specifically on the parameters {x,y}. So you might instead also solve for one of them, I guess x since you appear to want solutions not in terms of x, so leaving y to act as a symbolic parameter will have this effect.
Solve[y == x^2 && a == x, {a, x}]
(* Out[97]= {{a -> -Sqrt[y], x -> -Sqrt[y]}, {a -> Sqrt[y], x -> Sqrt[y]}} *)
Alternatively there is the undocumented allowing of the third variable to represent variables to eliminate. As this comprises a conflict with the intended and documented third argument (as a domain of interest), there is a warning message.
Solve[y == x^2 && a == x, a, x]
(* During evaluation of In[96]:= Solve::bdomv: Warning: x is not a valid domain specification. Assuming it is a variable to eliminate.
Out[96]= {{a -> -Sqrt[y]}, {a -> Sqrt[y]}} *)
Also of relevance is the MaxExtraConditions option, as this allows one to find nongeneric solutions that lie in a space no smaller than a given codimension (it will return conditions that specify said space).
Solve[y == x^2 && a == x, a, MaxExtraConditions -> 1]
(* Out[98]= {{a -> ConditionalExpression[x, x^2 - y == 0]}} *)
This has the limitation that one cannot specify how to “order” the parameters {x,y} and, in particular, we get a perfectly correct solution that is not give a as an explicit function of y.
Exactly. I’m seeking a description of a in terms of y and only y. (I’m working on a real-world problem more complicated than my example here, but for my example I’ve tried to distill the essentials.)
Today I’ve discovered Mathematica’s Eliminate function, and its docs link to related tutorials on Eliminate/Solve/Reduce which I’ll study imminently. And I find a construct giving me exactly the solution I was seeking:
Per refguide page for Solve: “Solve gives generic solutions only.
Solutions that are valid only when continuous parameters satisfy
equations are removed. Other solutions that are only conditionally
valid are expressed as ConditionalExpression objects.”
The middle quoted refguide-sentence warned me my attempt would fail, but I overlooked it. The first sentence is over my head: I don’t understand what “generic” means in this context. P.S. I’ve just found a tutorial “Generic and Non-Generic Solutions”, so I’ll look there for the answer.
In your first code-example, the output includes the answer I was seeking. I don’t yet understanding the meaning of {a,x} in your input, but I should get a handle on it when I read these tutorials.
Your second code-example produces exactly the output I was seeking.
there is the undocumented allowing of the third variable to represent
variables to eliminate
I notice also in the tutorial “Eliminating Variables”:
Solve[eqns,vars,elims] find solutions for vars, eliminating the
variables elims