0

When I try to solve a transcendental equation such as $e^{-2x}+e^{-3x}=x$ with Reduce I use the following:

Reduce[E^(-2 x) + E^(-3 x) == x, x, Reals]

With which I get the answer:

x == Root[{-1 - E^#1 + E^(3 #1) #1 &, 0.53889837536301031581}]

How can I get the root, which is nothing but the 0.538 898… answer I get in the second place of Root? I need it to do further calculations, thus, I need the value in a variable.

mov0021
  • 1
  • 1
  • 2
    Root object represents an exact solution and you should not transform it to a numerical approximation in general. In this case you seem to be satisfied with a numerical result however Root object is much stronger. More on this subject you can find e.g. in How do I work with Root objects? – Artes May 03 '21 at 21:46

1 Answers1

1

Try

var = N[x/.ToRules[Reduce[E^(-2 x) + E^(-3 x) == x, x, Reals] ]]

which returns

0.538898

and assigns the value to var

Bill
  • 12,001
  • 12
  • 13
  • Sweet. It works smooth. Thanks! I still cannot cast my vote, but this feedback will help. – mov0021 May 03 '21 at 21:28
  • Wonderful. Thanks. Please be careful with that. Always check to make certain that things are correct in every case. For example, does it do what you expect when Reduce returns two roots? Or three? And try to have a good time with this – Bill May 03 '21 at 21:34
  • Oh, God! I forgot. My approached is generalised if I get two roots. Example:

    Reduce[E^(0.3*x) + E^(-0.9* x) == x, x, Reals]

    This gave me two answers (with an error related to the inexact coefficients): x == 1.97921 || x == 5.93163

    So, how can I get both values in different variables?

    – mov0021 May 03 '21 at 21:52
  • Perhaps my warnings helped. That is why I write them. So if you look at the documentation for ToRules you should see an example similar to {ToRules[Reduce[E^(0.3*x) + E^(-0.9* x) == x, x, Reals]]} and that has turns each of the == into -> Now we want to extract those two values. We do that using this x/.{ToRules[Reduce[E^(0.3*x) + E^(-0.9* x) == x, x, Reals]]} Next, there are serious error messages from Mathematica, and there are other messages that are just cautions. The message you saw was a caution, it said to finish it needed to imagine your decimal constants were exact. OK? – Bill May 04 '21 at 01:51
  • 1
    And {var1,var2}=x/.{ToRules[Reduce[E^(0.3*x) + E^(-0.9* x) == x, x, Reals]]} assigns the first value to var1 and the second value to var2. See if you can study the help system and try to figure out why some of this is working. That will help you gain skill and be able to figure out more of your next problem. But there is LOTS to learn. Good luck. – Bill May 04 '21 at 01:54