Re: Solve vs Reduce
- To: mathgroup at smc.vnet.net
- Subject: [mg94678] Re: [mg94627] Solve vs Reduce
- From: Adam Strzebonski <adams at wolfram.com>
- Date: Sat, 20 Dec 2008 06:20:07 -0500 (EST)
- References: <200812181220.HAA00318@smc.vnet.net> <1EF82055-5EB8-4070-9684-56583245EAB2@mimuw.edu.pl> <EEDC4D88C587AB4F96F5E092A0514BE5075E40CA@01-orion.intra.eiaj.ch> <4A1767FA-065E-42D3-AE0D-16981982A54A@mimuw.edu.pl>
- Reply-to: adams at wolfram.com
Dear Andrzej and Florian, The difference between Solve and Reduce is in how they select which subexpressions should be considered independent parameters. Variables specified in the variable list are considered independent. Reduce replaces all listed variables with new symbolic variables. Hence in Reduce[equations, Dt[y, t]], Dt[y, t] gets replaced with a new variable. In[2]:= equations/.Dt[y, t]->v 5 2 -5 (v + Dt[x, t]) -2 v Out[2]= {----- == -, ----------------- == ----, Dt[x, t] == 1, x == 5} x + y y 2 2 (x + y) y Now we need to decide what are the parameters. Both Reduce and Solve start with collecting non-numeric subexpressions that appear at the algebraic level and are not listed as variables: {x, y, Dt[x, t]} At this point Reduce and Solve differ. Solve treats these subexpressions as independent parameters (except, I think, that if it gets a solution in which parameters must satisfy an equation it uses the original form of the parameters to check whether the equation is always satisfied). Equations 1, 3, 4 do not contain the variable, hence Solve treats them as assumptions on parameters In[3]:= Solve[Part[equations, {1, 3, 4}], {x, y, Dt[x, t]}] 10 Out[3]= {{x -> 5, y -> --, Dt[x, t] -> 1}} 3 and then it uses the assumptions to solve for the variable In[4]:= Solve[%2[[2]]/.%, v] 2 Out[4]= {{v -> -}} 3 Reduce does not allow parameters that are subexpressions of other parameters, that is f[x] and g[x] can be treated as independent parameters, but x and f[x] cannot. Hence in our example Reduce considers Dt[x, t] to be a function of x. Dt[x, t] is removed from the parameter list and Reduce looks for new parameters at algebraic level in arguments of Dt. So we get a new list of parameters {x, y, t} and now no parameter is a subexpression of another parameter so this is the final parameter list used by Reduce. Reduce does not know how to solve equations involving an unknown function Dt, so it solves the algebraic equations it knows how to solve In[5]:= Reduce[Part[%2, {1, 4}], {x, y, t, v}] 10 Out[5]= x == 5 && y == -- 3 and then it replaces the solutions back in the remaining equations In[6]:= Part[%2, {2, 3}]/.ToRules[%] -9 v -9 v Out[6]= {---- == ----, False} 125 50 Since one equation evaluated to False, because Dt[5, t] evaluates to zero, the whole system has no solutions. If you specify variable list {Dt[y, t], Dt[x, t], x, y} in Reduce, the elements of the variable list are considered independent and get replaced with new symbolic variables: In[7]:= equations/.Thread[{Dt[y, t], Dt[x, t], x, y}-> {v1, v2, v3, v4}] 5 2 -5 (v1 + v2) -2 v1 Out[7]= {------- == --, ------------ == -----, v2 == 1, v3 == 5} v3 + v4 v4 2 2 (v3 + v4) v4 The resulting algebraic system has a solution: In[8]:= Reduce[%, {v1, v2, v3, v4}] 2 10 Out[8]= v1 == - && v2 == 1 && v3 == 5 && v4 == -- 3 3 I am not quite sure why this gives no solutions In[9]:= Solve[equations, {Dt[y, t], Dt[x, t], x, y}] Out[9]= {} Possibly Solve has some special code for variables that are derivatives (or possibly it is a bug; I will find out which it is). In any case, replacing Dt with a new symbol helps: In[10]:= Solve[equations/.Dt->dt, {Dt[y, t], Dt[x, t], x, y}/.Dt->dt] 10 2 10 Out[10]= {{dt[x, t] -> 1, dt[--, t] -> -, x -> 5, y -> --}} 3 3 3 Best Regards, Adam Strzebonski Wolfram Research Andrzej Kozlowski wrote: > Dear Jaccard, > > I think what Reduce and Solve do in such cases is to try to eliminate > variables, much like one does at school although by somewhat different > means (GroebnerBasis etc). Sometimes as a result of substitution that is > performed during elimination a derivative is evaluated. In such a case > you may end up with an inconsistent set of (algebraic) equations and > then both Solve and Reduce will notice that the equations are > inconsistent. Sometimes, however, the equations are brought to a final > ("reduced") form without any differentiation taking place. In that case, > even if the equations are inconsistent "as differential equations", this > will not be visible to Reduce or Solve because they are only aware of > algebraic inconsistency. > Whether the system is reduced to an algebraically inconsistent form or > not depends on the order in which the various eliminations are performed > and the final form that is considered by Solve and Reduce as not > requiring any further transformations. In both cases (Solve and Reduce) > which variables you explicit state as the variables to be solved (or > reduced) for affects both the order of elimination and the final form > that is returned, but Reduce and Solve use different conventions. I am > not sure if this is deliberate or just a side effect of the fact that > Reduce and Solve have been largely programmed by two different persons > (both well known to the regular readers of the MathGroup). Any more > detailed information on this matter would have to come form one of them ;-) > > With best regards > > Andrzej Kozlowski > > > On 19 Dec 2008, at 16:45, Jaccard Florian wrote: > >> Dear Andrzej, >> >> Thank you very much for your answer, and the time you take to help me. >> I?m still surprised with the way Reduce works? >> In fact, looking at your answer, I understand better why Mathematica?s >> Output is consistent in this case : >> >> In[1]:= equations = {5/(x + y) == 2/y,Dt[5/(x + y) == 2/y, t],Dt[x, t] >> == 1, x == 5}; >> In[2] := Reduce[equations, Dt[y, t]] >> >> Out[2]= False >> >> But why do I obtain the expected answer if I specify more variables to >> be solved for? >> >> In[3]:= Reduce[equations, {Dt[y, t],Dt[x, t], x, y}] >> >> Out[3]= Dt[y, t] == 2/3 && Dt[x, t] == 1 && x == 5 && y == 10/3 >> >> Here, Mathematica won't express one of the derivatives in terms of the >> other and y in terms of x... >> Isn't it strange that Reduce sees a contradiction in In[2], but not in >> In[3] ? >> >> Also funny : >> >> If I use Solve in the configuration where Reduce sees a contradiction, >> Solve doesn?t see one: >> >> In[4]:= Solve[equations, Dt[y, t]] >> >> Out[4]= {{Dt[y, t] -> 2/3}} >> >> But if I use Solve where Reduce doesn't see a contradiction, Solve >> sees one: >> >> In[5]:= Solve[equations, {Dt[y, t],Dt[x, t], x, y}] >> >> Out[5]= {} >> >> Even after a long time using Mathematica, I'm surprised! >> >> Best Regards, and Merry Christmas! >> >> Florian Jaccard >> >> >> -----Message d'origine----- >> De : Andrzej Kozlowski [mailto:akoz at mimuw.edu.pl] >> Envoyé : vendredi, 19. décembre 2008 02:04 >> À : Jaccard Florian >> Cc : mathgroup at smc.vnet.net >> Objet : Re: [mg94627] Solve vs Reduce >> >> >> On 18 Dec 2008, at 21:20, Jaccard Florian wrote: >> >>> Hello! >>> >>> I have the following system : >>> >>> In[1]:= equations = {5/(x + y) == 2/y, Dt[5/(x + y) == 2/y, = >>> t], Dt[x, t] >>> == 1, x == 5} >>> >>> As you can see, Solve manages very well to find Dt[y,t] : >>> >>> In[2]:= Solve[equations, Dt[y, t]] >>> >>> Out[2]= {{Dt[y, t] -> 2/3}} >>> >>> Why isn't Reduce able to find the solution? >>> >>> In[3]:= Reduce[equations, Dt[y, t]] >>> >>> Out[3]= False >>> >>> Regards, and thanks to all who will answer! >>> >>> Florian Jaccard >>> >>> >> >> >> The reason is (I am speculating here a bit) that Reduce attempts to >> solve all kind of equations, not essentially algebraic ones, so it >> does treat the derivatives in your equations as such rather than as >> mere names of variables occurring in the equations. Taking this into >> account your two equations >> >> In[42]:= Reduce[{Dt[x, t] == 1, x == 5}] >> Out[42]= False >> >> appear to be inconsistent, since the derivative of a constant can't be >> one. >> >> If you remove the equation Dt[x, t] == 1,the system will be solved: >> >> Reduce[{5/(x + y) == 2/y, >> -((5*(Dt[x, t] + Dt[y, t]))/(x + y)^2) == >> -((2*Dt[y, t])/y^2), x == 5}, {y, x, Dt[y, t]}] >> y == 10/3 && x == 5 && Dt[y, t] == 0 >> >> Note that this is a consistent solution (y is a constant and hence >> Dt[y,t]==0). If you include both Dt[x,t] and Dt[y,t] in the list of >> variables you will get a different looking solution: >> >> Reduce[{5/(x + y) == 2/y, -((5*(Dt[x, t] + Dt[y, t]))/(x + y)^2) == >> -((2*Dt[y, t])/y^2), x == 5}, {y, x, Dt[y, t], Dt[x, t]}] >> y == 10/3 && x == 5 && Dt[x, t] == (3*Dt[y, t])/2 >> >> Note that this is also consistent (even though both Dt[x, t] and Dt[y, >> t] must actually be zero). >> >> Also, note that if you removed from the system the equation x==5 >> instead of Dt[x,t]==1 you will not get a solution: >> >> Reduce[{5/(x + y) == 2/y, -((5*(Dt[x, t] + Dt[y, t]))/(x + y)^2) == >> -((2*Dt[y, t])/y^2), Dt[x, t] == 1}, Dt[y, t]] >> During evaluation of In[39]:= Reduce::nsmet:This system cannot be >> solved with the methods available to Reduce. >> >> Reduce[{5/(x + y) == 2/y, >> -((5*(Dt[x, t] + Dt[y, t]))/(x + y)^2) == >> -((2*Dt[y, t])/y^2), Dt[x, t] == 1}, Dt[y, t]] >> >> This is not surprising since in order to compute Dt[y,t], you would >> need to solve a differential equation, which it does not do. However, >> if you include both Dt[y,t] and Dt[x,t] among the variables to be >> solved for the system will be solved, since Reduce will now express >> one of the derivatives in terms of the other and y in terms of x (so >> it does not have to express them in terms of t) >> >> Reduce[{5/(x + y) == 2/y, >> -((5*(Dt[x, t] + Dt[y, t]))/(x + y)^2) == >> -((2*Dt[y, t])/y^2), Dt[x, t] == 1}, >> {Dt[y, t], Dt[x, t], x, y}] >> Dt[y, t] == 2/3 && Dt[x, t] == 1 && y == (2*x)/3 && >> x != 0 >> >> Finally, instead of the differential equation Dt[x, t] == 1 you use >> one of its solutions, for example, x==t, you will get: >> >> Reduce[{5/(x + y) == 2/y, -((5*(Dt[x, t] + Dt[y, t]))/(x + y)^2) == >> -((2*Dt[y, t])/y^2), x == t}, {Dt[y, t], x, y}, Reals] >> >> (t < 0 || t > 0) && Dt[y, t] == 2/3 && x == t && >> y == (2*x)/3 >> >> or >> >> Reduce[{5/(x + y) == 2/y, -((5*(Dt[x, t] + Dt[y, t]))/(x + y)^2) == >> -((2*Dt[y, t])/y^2), x == t}, {Dt[y, t], Dt[x, t], x, y}, Reals] >> >> (t < 0 || t > 0) && Dt[x, t] == (3*Dt[y, t])/2 && >> x == t && y == (2*x)/3 >> >> All of these look to me like valid and useful answers, demonstrating >> that Reduce can be used even in contexts in which I would not have >> tried to use it before I saw your post ;-) >> >> Andrzej Kozlowski >> >> >> >
- References:
- Solve vs Reduce
- From: "Jaccard Florian" <Florian.Jaccard@he-arc.ch>
- Solve vs Reduce