TransWikia.com

How can I control the following behavior of Reduce?

Mathematica Asked on May 12, 2021

Consider the following 3 lines of code:

Reduce[1. Log[3 - x] + 2. Log[1 + x] == 2.1972245773362196, x]
Reduce[1. Log[3 - x] + 2. Log[1 + x] == 2.1972245773362196 && x < 2, x]
Reduce[1. Log[3 - x] + 2. Log[1 + x] == 2.19722 && x < 2, x]

Which give the following output (and warning about exact representation which I have not included here)

Reduce[1. Log[3 - x] + 2. Log[1 + x] == 2.19722, x]

x == 1.30278 || x == 2.

x == 1.30276

Is there something I can change so that these give results that are more in line?

  • I am particularly interested in making the 2nd the the third agree (since x==2 does not satisfy x<2)

I realize this is likely an issue of precision. My difficulty is that the numbers (1.,2.,2.19722…) are coming from earlier parts of code (i.e. I am not manually entering such numbers).

Perhaps if I tell mathematica to work with a certain level of precision (somehow keep it exact, or maybe use SetPrecision?) the discrepancy will be resolved?

  • If so, is there I way I can tell mathematica to set precision locally (only for part of my notebook)?

One Answer

Closer inspection shows that Reduce is correct:

Reduce[1. Log[3 - x] + 2. Log[1 + x] == 2.1972245773362196 && x < 2, x] //
 Style[#, PrintPrecision -> 17] &
Reduce[1. Log[3 - x] + 2. Log[1 + x] == 2.19722 && x < 2.1, x] // 
 Style[#, PrintPrecision -> 17] &

(*
  x == 1.3027756377319955 || x == 1.9999999999999993
  x == 1.30275925064097   || x == 2.000013731662965
*)

I increased the range on x in the second one, so that we can see where the root moved to. If you don't want the second solution, change the inequality to x < 1.9; if you want both, change it to x < 2.1. If you want the second solution to be 2 exactly in the first call, you might have to use exact input. (In fact, changing the left-hand side to 2.19722457733621935 results in a root that is numericized to 2. precisely and is excluded by the inequality.) You could try using arbitrary precision numbers at the beginning of your computation, and improve the accuracy that way. It's hard to say since we can't inspect the computations that led to the Reduce command.

Correct answer by Michael E2 on May 12, 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