How to prevent mathematica rounding extremely small numbers to zero? Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Early vs. late application of arbitrary precisionProduct of large number with a very small number returns zero because Mathematica sets the very small number equal to zeroHow do I prevent this precision exception?Is there a way to globally set when to treat a very small number as zero?Prevent Mathematica to automatically evaluate Manipulate at startHow to flush machine underflows to zero and prevent conversion to arbitrary precision?How to set products of small variables to zeroHow to prevent Round with hided fractionsEvaluate numerically an extremely small numberHow to get rid of 0. (zero dot) without get rid of small number?How to make Mathematica show small and large results?How to display very small numbers in Mathematica?

Why is it faster to reheat something than it is to cook it?

What does 丫 mean? 丫是什么意思?

Google .dev domain strangely redirects to https

Is openssl rand command cryptographically secure?

Is there hard evidence that the grant peer review system performs significantly better than random?

Can an iPhone 7 be made to function as a NFC Tag?

Sally's older brother

Can two people see the same photon?

Co-worker has annoying ringtone

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

Weaponising the Grasp-at-a-Distance spell

A term for a woman complaining about things/begging in a cute/childish way

What is the role of と after a noun when it doesn't appear to count or list anything?

Simple HTTP Server

Tannaka duality for semisimple groups

How many time has Arya actually used Needle?

Should a wizard buy fine inks every time he want to copy spells into his spellbook?

Tips to organize LaTeX presentations for a semester

What does Turing mean by this statement?

Most effective melee weapons for arboreal combat? (pre-gunpowder technology)

Why BitLocker does not use RSA

What does the writing on Poe's helmet say?

GDP with Intermediate Production

Why is the change of basis formula counter-intuitive? [See details]



How to prevent mathematica rounding extremely small numbers to zero?



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Early vs. late application of arbitrary precisionProduct of large number with a very small number returns zero because Mathematica sets the very small number equal to zeroHow do I prevent this precision exception?Is there a way to globally set when to treat a very small number as zero?Prevent Mathematica to automatically evaluate Manipulate at startHow to flush machine underflows to zero and prevent conversion to arbitrary precision?How to set products of small variables to zeroHow to prevent Round with hided fractionsEvaluate numerically an extremely small numberHow to get rid of 0. (zero dot) without get rid of small number?How to make Mathematica show small and large results?How to display very small numbers in Mathematica?










4












$begingroup$


I have a function that, while the maths itself is unimportant, at certain values it results in a very large number multiplying a very small number. E.g. 10^450000 * 10^-449998. As you can see, this should output the more-sensible number 10^2. However Mathematica is rounding the small number to zero thus the whole calculation breaks down. How can I prevent this? I've played with MinNumber and MachinePrecision but neither seem to fix the issue.



Thanks in advance!



Edit: Including the equation as requested:



$exp[cfracomega^2sigma^2] BesselK[1,cfracsqrt(cfracomegasigma^2)sqrt(cfracsigma^2omega^3)]$



Equation breaks down for $sigma<0.01*omega$ and generally unreliable below $sigma<0.04*omega$



Edit2: And the Mathematica code!



bessktot[ω0_, σ_] := BesselK[1, Sqrt[ω0/σ^2]/Sqrt[σ^2/ω0^3]]
expcalctot[ω0_, σ_] := E^(ω0^2/σ^2);
ω0 = 2 [Pi] 10^12;
σ[BWpc_] := BWpc/100 ω0;
σt = σ[1]
bessktot[ω0, σt]
expcalctot[ω0, σt]
expcalctot[ω0, σt]*bessktot[ω0, σt]


Edit3: Thanks Bob Hanlon, (I can't comment back on your answer yet). Your answer works for certain values input to the bessel. The problem appears to be even more fundamental than I realised. It appears Mathematica can't calculate non-integer $BesselK[1,x]$ functions when $x>741$. Is there a way around this?










share|improve this question









New contributor




Andrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    On my machine, even with machine precision exponents, 10^45000000000000.*10^-44999999999998. outputs 1.0 * 10^2 from a fresh startup. It should only start rounding to 0 if it runs out of precision during the calculation, one of the intermediate functions does not handle arbitrary precision arithmetic (not common, but some don't), if it's explicitly told to start rounding somewhere, or if something is actually multiplied by 0. We will need a bit more code to diagnose what's actually going on, so please consider posting your function.
    $endgroup$
    – eyorble
    Apr 16 at 13:55










  • $begingroup$
    @eyorblade 0^45000000000000. is certainly no a machine precision number: Precision[110^45000000000000.].
    $endgroup$
    – Henrik Schumacher
    Apr 16 at 13:59










  • $begingroup$
    @HenrikSchumacher In a_^b_, the b is machine precision, is it not? The resulting value is not, obviously, because there's any precision tracking at all. I suspect Mathematica knows what it's doing here, in that with exact a the precision isn't lost very quickly at all, but the exponent isn't the source of the uncertainty in this case.
    $endgroup$
    – eyorble
    Apr 16 at 14:03











  • $begingroup$
    If the issue is with Mathematica code, please post the Mathematica code rather than a LaTeX representation.
    $endgroup$
    – JimB
    Apr 16 at 14:14






  • 2




    $begingroup$
    @Andrew When I approved your edit, I notice that you have two different accounts, both with the same name. I do not know how that happened, but you should be able to combine the two. Then, you will not need the approval of others to edit your own question.
    $endgroup$
    – bbgodfrey
    Apr 16 at 17:39















4












$begingroup$


I have a function that, while the maths itself is unimportant, at certain values it results in a very large number multiplying a very small number. E.g. 10^450000 * 10^-449998. As you can see, this should output the more-sensible number 10^2. However Mathematica is rounding the small number to zero thus the whole calculation breaks down. How can I prevent this? I've played with MinNumber and MachinePrecision but neither seem to fix the issue.



Thanks in advance!



Edit: Including the equation as requested:



$exp[cfracomega^2sigma^2] BesselK[1,cfracsqrt(cfracomegasigma^2)sqrt(cfracsigma^2omega^3)]$



Equation breaks down for $sigma<0.01*omega$ and generally unreliable below $sigma<0.04*omega$



Edit2: And the Mathematica code!



bessktot[ω0_, σ_] := BesselK[1, Sqrt[ω0/σ^2]/Sqrt[σ^2/ω0^3]]
expcalctot[ω0_, σ_] := E^(ω0^2/σ^2);
ω0 = 2 [Pi] 10^12;
σ[BWpc_] := BWpc/100 ω0;
σt = σ[1]
bessktot[ω0, σt]
expcalctot[ω0, σt]
expcalctot[ω0, σt]*bessktot[ω0, σt]


Edit3: Thanks Bob Hanlon, (I can't comment back on your answer yet). Your answer works for certain values input to the bessel. The problem appears to be even more fundamental than I realised. It appears Mathematica can't calculate non-integer $BesselK[1,x]$ functions when $x>741$. Is there a way around this?










share|improve this question









New contributor




Andrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    On my machine, even with machine precision exponents, 10^45000000000000.*10^-44999999999998. outputs 1.0 * 10^2 from a fresh startup. It should only start rounding to 0 if it runs out of precision during the calculation, one of the intermediate functions does not handle arbitrary precision arithmetic (not common, but some don't), if it's explicitly told to start rounding somewhere, or if something is actually multiplied by 0. We will need a bit more code to diagnose what's actually going on, so please consider posting your function.
    $endgroup$
    – eyorble
    Apr 16 at 13:55










  • $begingroup$
    @eyorblade 0^45000000000000. is certainly no a machine precision number: Precision[110^45000000000000.].
    $endgroup$
    – Henrik Schumacher
    Apr 16 at 13:59










  • $begingroup$
    @HenrikSchumacher In a_^b_, the b is machine precision, is it not? The resulting value is not, obviously, because there's any precision tracking at all. I suspect Mathematica knows what it's doing here, in that with exact a the precision isn't lost very quickly at all, but the exponent isn't the source of the uncertainty in this case.
    $endgroup$
    – eyorble
    Apr 16 at 14:03











  • $begingroup$
    If the issue is with Mathematica code, please post the Mathematica code rather than a LaTeX representation.
    $endgroup$
    – JimB
    Apr 16 at 14:14






  • 2




    $begingroup$
    @Andrew When I approved your edit, I notice that you have two different accounts, both with the same name. I do not know how that happened, but you should be able to combine the two. Then, you will not need the approval of others to edit your own question.
    $endgroup$
    – bbgodfrey
    Apr 16 at 17:39













4












4








4


1



$begingroup$


I have a function that, while the maths itself is unimportant, at certain values it results in a very large number multiplying a very small number. E.g. 10^450000 * 10^-449998. As you can see, this should output the more-sensible number 10^2. However Mathematica is rounding the small number to zero thus the whole calculation breaks down. How can I prevent this? I've played with MinNumber and MachinePrecision but neither seem to fix the issue.



Thanks in advance!



Edit: Including the equation as requested:



$exp[cfracomega^2sigma^2] BesselK[1,cfracsqrt(cfracomegasigma^2)sqrt(cfracsigma^2omega^3)]$



Equation breaks down for $sigma<0.01*omega$ and generally unreliable below $sigma<0.04*omega$



Edit2: And the Mathematica code!



bessktot[ω0_, σ_] := BesselK[1, Sqrt[ω0/σ^2]/Sqrt[σ^2/ω0^3]]
expcalctot[ω0_, σ_] := E^(ω0^2/σ^2);
ω0 = 2 [Pi] 10^12;
σ[BWpc_] := BWpc/100 ω0;
σt = σ[1]
bessktot[ω0, σt]
expcalctot[ω0, σt]
expcalctot[ω0, σt]*bessktot[ω0, σt]


Edit3: Thanks Bob Hanlon, (I can't comment back on your answer yet). Your answer works for certain values input to the bessel. The problem appears to be even more fundamental than I realised. It appears Mathematica can't calculate non-integer $BesselK[1,x]$ functions when $x>741$. Is there a way around this?










share|improve this question









New contributor




Andrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




I have a function that, while the maths itself is unimportant, at certain values it results in a very large number multiplying a very small number. E.g. 10^450000 * 10^-449998. As you can see, this should output the more-sensible number 10^2. However Mathematica is rounding the small number to zero thus the whole calculation breaks down. How can I prevent this? I've played with MinNumber and MachinePrecision but neither seem to fix the issue.



Thanks in advance!



Edit: Including the equation as requested:



$exp[cfracomega^2sigma^2] BesselK[1,cfracsqrt(cfracomegasigma^2)sqrt(cfracsigma^2omega^3)]$



Equation breaks down for $sigma<0.01*omega$ and generally unreliable below $sigma<0.04*omega$



Edit2: And the Mathematica code!



bessktot[ω0_, σ_] := BesselK[1, Sqrt[ω0/σ^2]/Sqrt[σ^2/ω0^3]]
expcalctot[ω0_, σ_] := E^(ω0^2/σ^2);
ω0 = 2 [Pi] 10^12;
σ[BWpc_] := BWpc/100 ω0;
σt = σ[1]
bessktot[ω0, σt]
expcalctot[ω0, σt]
expcalctot[ω0, σt]*bessktot[ω0, σt]


Edit3: Thanks Bob Hanlon, (I can't comment back on your answer yet). Your answer works for certain values input to the bessel. The problem appears to be even more fundamental than I realised. It appears Mathematica can't calculate non-integer $BesselK[1,x]$ functions when $x>741$. Is there a way around this?







equation-solving numerics evaluation






share|improve this question









New contributor




Andrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Andrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Apr 16 at 17:34









Andrew

32




32






New contributor




Andrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 16 at 13:44









AndrewAndrew

212




212




New contributor




Andrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Andrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Andrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • $begingroup$
    On my machine, even with machine precision exponents, 10^45000000000000.*10^-44999999999998. outputs 1.0 * 10^2 from a fresh startup. It should only start rounding to 0 if it runs out of precision during the calculation, one of the intermediate functions does not handle arbitrary precision arithmetic (not common, but some don't), if it's explicitly told to start rounding somewhere, or if something is actually multiplied by 0. We will need a bit more code to diagnose what's actually going on, so please consider posting your function.
    $endgroup$
    – eyorble
    Apr 16 at 13:55










  • $begingroup$
    @eyorblade 0^45000000000000. is certainly no a machine precision number: Precision[110^45000000000000.].
    $endgroup$
    – Henrik Schumacher
    Apr 16 at 13:59










  • $begingroup$
    @HenrikSchumacher In a_^b_, the b is machine precision, is it not? The resulting value is not, obviously, because there's any precision tracking at all. I suspect Mathematica knows what it's doing here, in that with exact a the precision isn't lost very quickly at all, but the exponent isn't the source of the uncertainty in this case.
    $endgroup$
    – eyorble
    Apr 16 at 14:03











  • $begingroup$
    If the issue is with Mathematica code, please post the Mathematica code rather than a LaTeX representation.
    $endgroup$
    – JimB
    Apr 16 at 14:14






  • 2




    $begingroup$
    @Andrew When I approved your edit, I notice that you have two different accounts, both with the same name. I do not know how that happened, but you should be able to combine the two. Then, you will not need the approval of others to edit your own question.
    $endgroup$
    – bbgodfrey
    Apr 16 at 17:39
















  • $begingroup$
    On my machine, even with machine precision exponents, 10^45000000000000.*10^-44999999999998. outputs 1.0 * 10^2 from a fresh startup. It should only start rounding to 0 if it runs out of precision during the calculation, one of the intermediate functions does not handle arbitrary precision arithmetic (not common, but some don't), if it's explicitly told to start rounding somewhere, or if something is actually multiplied by 0. We will need a bit more code to diagnose what's actually going on, so please consider posting your function.
    $endgroup$
    – eyorble
    Apr 16 at 13:55










  • $begingroup$
    @eyorblade 0^45000000000000. is certainly no a machine precision number: Precision[110^45000000000000.].
    $endgroup$
    – Henrik Schumacher
    Apr 16 at 13:59










  • $begingroup$
    @HenrikSchumacher In a_^b_, the b is machine precision, is it not? The resulting value is not, obviously, because there's any precision tracking at all. I suspect Mathematica knows what it's doing here, in that with exact a the precision isn't lost very quickly at all, but the exponent isn't the source of the uncertainty in this case.
    $endgroup$
    – eyorble
    Apr 16 at 14:03











  • $begingroup$
    If the issue is with Mathematica code, please post the Mathematica code rather than a LaTeX representation.
    $endgroup$
    – JimB
    Apr 16 at 14:14






  • 2




    $begingroup$
    @Andrew When I approved your edit, I notice that you have two different accounts, both with the same name. I do not know how that happened, but you should be able to combine the two. Then, you will not need the approval of others to edit your own question.
    $endgroup$
    – bbgodfrey
    Apr 16 at 17:39















$begingroup$
On my machine, even with machine precision exponents, 10^45000000000000.*10^-44999999999998. outputs 1.0 * 10^2 from a fresh startup. It should only start rounding to 0 if it runs out of precision during the calculation, one of the intermediate functions does not handle arbitrary precision arithmetic (not common, but some don't), if it's explicitly told to start rounding somewhere, or if something is actually multiplied by 0. We will need a bit more code to diagnose what's actually going on, so please consider posting your function.
$endgroup$
– eyorble
Apr 16 at 13:55




$begingroup$
On my machine, even with machine precision exponents, 10^45000000000000.*10^-44999999999998. outputs 1.0 * 10^2 from a fresh startup. It should only start rounding to 0 if it runs out of precision during the calculation, one of the intermediate functions does not handle arbitrary precision arithmetic (not common, but some don't), if it's explicitly told to start rounding somewhere, or if something is actually multiplied by 0. We will need a bit more code to diagnose what's actually going on, so please consider posting your function.
$endgroup$
– eyorble
Apr 16 at 13:55












$begingroup$
@eyorblade 0^45000000000000. is certainly no a machine precision number: Precision[110^45000000000000.].
$endgroup$
– Henrik Schumacher
Apr 16 at 13:59




$begingroup$
@eyorblade 0^45000000000000. is certainly no a machine precision number: Precision[110^45000000000000.].
$endgroup$
– Henrik Schumacher
Apr 16 at 13:59












$begingroup$
@HenrikSchumacher In a_^b_, the b is machine precision, is it not? The resulting value is not, obviously, because there's any precision tracking at all. I suspect Mathematica knows what it's doing here, in that with exact a the precision isn't lost very quickly at all, but the exponent isn't the source of the uncertainty in this case.
$endgroup$
– eyorble
Apr 16 at 14:03





$begingroup$
@HenrikSchumacher In a_^b_, the b is machine precision, is it not? The resulting value is not, obviously, because there's any precision tracking at all. I suspect Mathematica knows what it's doing here, in that with exact a the precision isn't lost very quickly at all, but the exponent isn't the source of the uncertainty in this case.
$endgroup$
– eyorble
Apr 16 at 14:03













$begingroup$
If the issue is with Mathematica code, please post the Mathematica code rather than a LaTeX representation.
$endgroup$
– JimB
Apr 16 at 14:14




$begingroup$
If the issue is with Mathematica code, please post the Mathematica code rather than a LaTeX representation.
$endgroup$
– JimB
Apr 16 at 14:14




2




2




$begingroup$
@Andrew When I approved your edit, I notice that you have two different accounts, both with the same name. I do not know how that happened, but you should be able to combine the two. Then, you will not need the approval of others to edit your own question.
$endgroup$
– bbgodfrey
Apr 16 at 17:39




$begingroup$
@Andrew When I approved your edit, I notice that you have two different accounts, both with the same name. I do not know how that happened, but you should be able to combine the two. Then, you will not need the approval of others to edit your own question.
$endgroup$
– bbgodfrey
Apr 16 at 17:39










1 Answer
1






active

oldest

votes


















7












$begingroup$

There was a change in handling underflow in later versions.



$Version

(* "11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)" *)

Clear["Global`*"]

bessktot[ω0_, σ_] :=
BesselK[1, Sqrt[ω0/σ^2]/Sqrt[σ^2/ω0^3]];
expcalctot[ω0_, σ_] := E^(ω0^2/σ^2);
ω0 = 2 π 10^12;
σ[BWpc_] := BWpc/100 ω0;
σt = σ[1];


MachinePrecision is insufficient,



(expr = expcalctot[ω0, σt]*bessktot[ω0, σt]) // N

(* 0. *)


Use arbitrary precision



expr // N[#, $MachinePrecision] &

(* 0.01253361135127051 *)

expr // N[#, 20] &

(* 0.012533611351270505734 *)


EDIT: For large input to BesselK you need to control the precision of the input.



BesselK[1, #] & /@ 801., 801.`20, SetPrecision[801., 20]

(* 0., 5.9781508629496523*10^-350, 5.9781508629496523*10^-350 *)





share|improve this answer











$endgroup$













    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Andrew is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f195302%2fhow-to-prevent-mathematica-rounding-extremely-small-numbers-to-zero%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7












    $begingroup$

    There was a change in handling underflow in later versions.



    $Version

    (* "11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)" *)

    Clear["Global`*"]

    bessktot[ω0_, σ_] :=
    BesselK[1, Sqrt[ω0/σ^2]/Sqrt[σ^2/ω0^3]];
    expcalctot[ω0_, σ_] := E^(ω0^2/σ^2);
    ω0 = 2 π 10^12;
    σ[BWpc_] := BWpc/100 ω0;
    σt = σ[1];


    MachinePrecision is insufficient,



    (expr = expcalctot[ω0, σt]*bessktot[ω0, σt]) // N

    (* 0. *)


    Use arbitrary precision



    expr // N[#, $MachinePrecision] &

    (* 0.01253361135127051 *)

    expr // N[#, 20] &

    (* 0.012533611351270505734 *)


    EDIT: For large input to BesselK you need to control the precision of the input.



    BesselK[1, #] & /@ 801., 801.`20, SetPrecision[801., 20]

    (* 0., 5.9781508629496523*10^-350, 5.9781508629496523*10^-350 *)





    share|improve this answer











    $endgroup$

















      7












      $begingroup$

      There was a change in handling underflow in later versions.



      $Version

      (* "11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)" *)

      Clear["Global`*"]

      bessktot[ω0_, σ_] :=
      BesselK[1, Sqrt[ω0/σ^2]/Sqrt[σ^2/ω0^3]];
      expcalctot[ω0_, σ_] := E^(ω0^2/σ^2);
      ω0 = 2 π 10^12;
      σ[BWpc_] := BWpc/100 ω0;
      σt = σ[1];


      MachinePrecision is insufficient,



      (expr = expcalctot[ω0, σt]*bessktot[ω0, σt]) // N

      (* 0. *)


      Use arbitrary precision



      expr // N[#, $MachinePrecision] &

      (* 0.01253361135127051 *)

      expr // N[#, 20] &

      (* 0.012533611351270505734 *)


      EDIT: For large input to BesselK you need to control the precision of the input.



      BesselK[1, #] & /@ 801., 801.`20, SetPrecision[801., 20]

      (* 0., 5.9781508629496523*10^-350, 5.9781508629496523*10^-350 *)





      share|improve this answer











      $endgroup$















        7












        7








        7





        $begingroup$

        There was a change in handling underflow in later versions.



        $Version

        (* "11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)" *)

        Clear["Global`*"]

        bessktot[ω0_, σ_] :=
        BesselK[1, Sqrt[ω0/σ^2]/Sqrt[σ^2/ω0^3]];
        expcalctot[ω0_, σ_] := E^(ω0^2/σ^2);
        ω0 = 2 π 10^12;
        σ[BWpc_] := BWpc/100 ω0;
        σt = σ[1];


        MachinePrecision is insufficient,



        (expr = expcalctot[ω0, σt]*bessktot[ω0, σt]) // N

        (* 0. *)


        Use arbitrary precision



        expr // N[#, $MachinePrecision] &

        (* 0.01253361135127051 *)

        expr // N[#, 20] &

        (* 0.012533611351270505734 *)


        EDIT: For large input to BesselK you need to control the precision of the input.



        BesselK[1, #] & /@ 801., 801.`20, SetPrecision[801., 20]

        (* 0., 5.9781508629496523*10^-350, 5.9781508629496523*10^-350 *)





        share|improve this answer











        $endgroup$



        There was a change in handling underflow in later versions.



        $Version

        (* "11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)" *)

        Clear["Global`*"]

        bessktot[ω0_, σ_] :=
        BesselK[1, Sqrt[ω0/σ^2]/Sqrt[σ^2/ω0^3]];
        expcalctot[ω0_, σ_] := E^(ω0^2/σ^2);
        ω0 = 2 π 10^12;
        σ[BWpc_] := BWpc/100 ω0;
        σt = σ[1];


        MachinePrecision is insufficient,



        (expr = expcalctot[ω0, σt]*bessktot[ω0, σt]) // N

        (* 0. *)


        Use arbitrary precision



        expr // N[#, $MachinePrecision] &

        (* 0.01253361135127051 *)

        expr // N[#, 20] &

        (* 0.012533611351270505734 *)


        EDIT: For large input to BesselK you need to control the precision of the input.



        BesselK[1, #] & /@ 801., 801.`20, SetPrecision[801., 20]

        (* 0., 5.9781508629496523*10^-350, 5.9781508629496523*10^-350 *)






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 16 at 17:41

























        answered Apr 16 at 14:37









        Bob HanlonBob Hanlon

        61.8k33598




        61.8k33598




















            Andrew is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Andrew is a new contributor. Be nice, and check out our Code of Conduct.












            Andrew is a new contributor. Be nice, and check out our Code of Conduct.











            Andrew is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Mathematica Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f195302%2fhow-to-prevent-mathematica-rounding-extremely-small-numbers-to-zero%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Sum ergo cogito? 1 nng

            三茅街道4182Guuntc Dn precexpngmageondP