gidonwe
(Gidon W)
September 20, 2015, 1:25pm
1
Hello,
I am trying to solve for example the following equation
a + (b - y) (1 - y) x=0
where x is a variable and y is an unknown parameter.
I use:
SolveAlways[a + (b - y) (1 - y) x == 0, x]
and the solution is:
{{a → 0, b → y}, {a → 0, y → 1}}
I want only the first solution since y is an unknown parameter and in general doesn’t equal 1.
Is there a way to tell the program to treat y as a parameter and not to try and solve it for a specific y?
In the documentation for SolveAlways, hiding behind “Details and Options”, it says
SolveAlways produces relations between parameters that appear in eqns, but are not in the list of variables vars.
That, and the rest of the documentation, seems to strongly hint there is no obvious way to tell it to ignore y.
You can use a First[] function to extract first solution:
First@SolveAlways[a + (b - y)*(1 - y)*x == 0, x]
Or:
SolveAlways[a + (b - y)*(1 - y)*x == 0, x][[1]]
gidonwe
(Gidon W)
September 24, 2015, 2:44pm
4
Thanks but i want it from the beginning not to look for a solution for y.
When i solve an equation like this with hundreds of variables, solving it with SolveAlways takes a few seconds when looking for only one solution, and can take hours when there is more than one solution..
You can Select the solutions that do not give values to y:
Select[SolveAlways[a + (b - y)*(1 - y)*x == 0, x],
FreeQ[#, HoldPattern[y -> _]] &]
This seems to work too
Solve[Not@Eliminate[Not[a + (b - y)*(1 - y)*x == 0], x], {a, b}]
This it taken from the documentation of SolveAlways:
SolveAlways[eqns,vars] is equivalent to Solve[!Eliminate[!eqns,vars]]
By default the outer Solve solves for all the variables. You can tell it to only solve for a and b, and not for y.