TransWikia.com

Behavior of Solve with $Assumptions changed in 12.2

Mathematica Asked by Chris K on January 11, 2021

Something changed with Solve between versions 12.1 and 12.2.

12.1:

Solve[n == n E^(r (1 - n)), n]
(* Solve::ifun -- Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. *)
(* {{n -> 0}, {n -> 1}} *)

$Assumptions = {n >= 0};
Solve[n == n E^(r (1 - n)), n]
(* Solve::ifun -- Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. *)
(* {{n -> 0}, {n -> 1}} *)

12.2:

Solve[n == n E^(r (1 - n)), n]
(* Solve::ifun -- Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. *)
(* {{n -> 0}, {n -> 1}} *)

$Assumptions = {n >= 0};
Solve[n == n E^(r (1 - n)), n]

enter image description here

Is this an improvement or a bug? It seems hard for the condition ConditionalExpression[1, Re[r] == 0 || Re[r] > 0 || Re[r] < 0] not to hold, but maybe I’m overlooking something.

Two work-arounds:

$Assumptions = {n >= 0, r [Element] Reals};
Solve[n == n E^(r (1 - n)), n]

Solve[n == n E^(r (1 - n)), n, Reals]

both give {{n -> 0}, {n -> 1}} (no Solve::ifun either).

Another example, not fixable by including Reals:

$Assumptions = {n1 >= 0, n2 >= 0};
Solve[0 == n1 (1 - n1 - 0.5 n2), n1]

enter image description here

To be precise, my version is

$Version
(* 12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020) *)

Update:
So, I think I’ll just use Assumptions->{} to avoid these conditionals for now (while keeping $Assumptions set for use in Simplify).

One Answer

I think this is (seen by WRI as) an improvement, and the change is marked in the docs for Solve (noted in the comments). In the docs, it is also indicated how Assumptions are used:

So really, it just amounts to some syntactic sugar.

On V12.0 and V12.1,

Solve[n == n E^(r (1 - n)) && n >= 0, {n}]

gives a set of three solutions equivalent to the V12.2 result in the OP with $Assumptions = {n >= 0}. In V12.0, the second solution of the three is simply {n -> 1}, but Simplify@Solve[...] makes the results in all three versions identical.

In short, the new use of $Assumptions/Assumptions does not seem to represent any major change in how solutions are computed. I suppose what is more worrying is that code that uses $Assumptions and Solve and further assumes Solve does not use $Assumptions might break. Might have to write Block[{$Assumptions = True}, Solve[...]] around all my instances of Solve now.

Correct answer by Michael E2 on January 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP