ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 13 Mar 2013 08:07:42 +0100How to treat with logarithm numerically when it becomes negative?https://ask.sagemath.org/question/9903/how-to-treat-with-logarithm-numerically-when-it-becomes-negative/I have a term log(f(x)) in my equations which I am trying to solve them numerically. But the solver does not solve, perhaps when the argument of the logarithm becomes negative. What should I write in the program when f(x)<0 in the loop in order not to loose the iteration?
ThanksTue, 12 Mar 2013 10:38:41 +0100https://ask.sagemath.org/question/9903/how-to-treat-with-logarithm-numerically-when-it-becomes-negative/Comment by kcrisman for <p>I have a term log(f(x)) in my equations which I am trying to solve them numerically. But the solver does not solve, perhaps when the argument of the logarithm becomes negative. What should I write in the program when f(x)<0 in the loop in order not to loose the iteration?</p>
<p>Thanks</p>
https://ask.sagemath.org/question/9903/how-to-treat-with-logarithm-numerically-when-it-becomes-negative/?comment=18077#post-id-18077I think you have to provide more details. In general, log of a negative number does make sense, but it is multi-valued.Tue, 12 Mar 2013 11:09:40 +0100https://ask.sagemath.org/question/9903/how-to-treat-with-logarithm-numerically-when-it-becomes-negative/?comment=18077#post-id-18077Comment by achrzesz for <p>I have a term log(f(x)) in my equations which I am trying to solve them numerically. But the solver does not solve, perhaps when the argument of the logarithm becomes negative. What should I write in the program when f(x)<0 in the loop in order not to loose the iteration?</p>
<p>Thanks</p>
https://ask.sagemath.org/question/9903/how-to-treat-with-logarithm-numerically-when-it-becomes-negative/?comment=18074#post-id-18074Have you tried:
find_root(log(x*x-x),-2,0)
-0.6180339887498988
find_root(log(x*x-x),-2,2)
1.6180339887498947Wed, 13 Mar 2013 08:07:42 +0100https://ask.sagemath.org/question/9903/how-to-treat-with-logarithm-numerically-when-it-becomes-negative/?comment=18074#post-id-18074Comment by ela for <p>I have a term log(f(x)) in my equations which I am trying to solve them numerically. But the solver does not solve, perhaps when the argument of the logarithm becomes negative. What should I write in the program when f(x)<0 in the loop in order not to loose the iteration?</p>
<p>Thanks</p>
https://ask.sagemath.org/question/9903/how-to-treat-with-logarithm-numerically-when-it-becomes-negative/?comment=18075#post-id-18075you mean detail in the program?Wed, 13 Mar 2013 03:55:57 +0100https://ask.sagemath.org/question/9903/how-to-treat-with-logarithm-numerically-when-it-becomes-negative/?comment=18075#post-id-18075