I have the following function:

f3 = (99. (2154.43 - 100. lh^2.))/lh^1. - (0.0609773 ((2154.43 - 100.lh^2.)/lh^1.)^7.30317)/(-4.64159 - lh)^6.30317

If I plot it, in that specific interval, I get:

Plot[{f3}, {lh, 4.45, 4.85}]

enter image description here

If instead I plot both the real and the imaginary part I get:

Plot[{Re[f3], Im[f3]}, {lh, 4.45, 4.85}, PlotTheme -> "Detailed"

[2]: https://i.stack.imgur.com/A5hkm.png

I don't understand why when I plot only the real part, the function is not shown for values smaller than 4.64. Indeed, the imaginary part is not zero for values greater than 4.64 either, as is shown in the following graph:

Plot[{Im[f3]}, {lh, 4.78, 4.8}, PlotTheme -> "Detailed"]

enter image description here

  • 1
    $\begingroup$ Plot[{f3}, {lh, 4.45, 4.85}] only plots if the argument f3 is real! Only forx>4.64 the imaginary part of f3 vanishs! $\endgroup$ – Ulrich Neumann Nov 7 '18 at 11:36
  • $\begingroup$ Does this mean that there is a threshold regarding the imaginary part of a complex number, below which M. treats it as a Real number? $\endgroup$ – Tecon Nov 7 '18 at 11:40
  • $\begingroup$ No I don't think so. Plot only tries to find the region where f3 is real. That's why for example Plot[Exp[I x],{x,0,2 Pi}] gives no output! $\endgroup$ – Ulrich Neumann Nov 7 '18 at 11:46
  • 1
    $\begingroup$ Plot is a numerical(!) function. Values smaller 10^-13(depending on the WorkingPrecision) are assumed to be zero! $\endgroup$ – Ulrich Neumann Nov 7 '18 at 12:22
  • 1
    $\begingroup$ You are encountering precision issues that result from doing calculations using machine precision. To get precise calculations you need to track and control precision by using exact or arbitrary-precision numbers. To avoid conflicts with subsequent specification of desired working precision, start by expressing f3 with exact numbers by using Rationalize. $\endgroup$ – Bob Hanlon Nov 8 '18 at 4:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.