How to deal with a Dirac delta function numerically?How to correctly use DSolve when the force is an impulse...

Is residual finiteness a quasi isometry invariant for f.g. groups?

Is there a better way to make this?

just upgraded iMac late 2015 ram from 12 GB to 28 GB and it became too slow to use

Does Windows 10's telemetry include sending *.doc files if Word crashed?

How should I handle players who ignore the session zero agreement?

Every character has a name - does this lead to too many named characters?

Is there any differences between “gucken” and “schauen”?

How to acknowledge an embarrassing job interview, now that I work directly with the interviewer?

Does fast page mode apply to ROM?

Can I write a book of my D&D game?

Overfitting and Underfitting

What to do if authors don't respond to my serious concerns about their paper?

Slow moving projectiles from a hand-held weapon - how do they reach the target?

Why would the Pakistan airspace closure cancel flights not headed to Pakistan itself?

Citing paywalled articles accessed via illegal web sharing

Using only 1s, make 29 with the minimum number of digits

Would a National Army of mercenaries be a feasible idea?

What's the most convenient time of year in the USA to end the world?

How can I deal with a significant flaw I found in my previous supervisor’s paper?

How to install Dc++ on Lubuntu?

What does Cypher mean when he says Neo is "gonna pop"?

What is this metal M-shaped device for?

If I delete my router's history can my ISP still provide it to my parents?

What to do when being responsible for data protection in your lab, yet advice is ignored?



How to deal with a Dirac delta function numerically?


How to correctly use DSolve when the force is an impulse (dirac delta) and initial conditions are not zeroHow could I solve this Reaction-Diffusion PDE using mathematica?NDsolve of partial differential equation - integral of the functionSolving two-dimensional heat balance equationHow to solve a system of coupled Partial differential equationsDSolve returns a Solve expressionSolving systems of partial differential equations with functions of different number of variablesCould anyone help me to solve the following differential equation?How to solve the time-dependent Schroedinger equation numerically?Solving a differential equation with an implicit function in NDSolve













1












$begingroup$


I need to solve some differential equations with a Dirac delta function. e.g. the source terms are like, $delta(x)$ and $partial_x delta(x)$.



Could I just use the Gaussian type function? e.g.



$$ delta(x-a) = frac{a_1}{sqrt{pi}}exp(-frac{(x-a)^2}{a_1}),$$ and,
$$ partial_x delta(x-a) = - frac{2}{sqrt{pi}}(x-a)exp(-frac{(x-a)^2}{a_1}) $$



where by setting e.g. $a_1=0.01$.



If the answer is yes, then how to choose the reasonable values of $a_1$ and $a_2$?



Thanks!










share|improve this question









$endgroup$








  • 2




    $begingroup$
    While this is an interesting (and hard) question, I think it's more suitable for math.stackexchange.com or scicomp.stackexchange.com
    $endgroup$
    – xzczd
    5 hours ago












  • $begingroup$
    What is your $a_2$?
    $endgroup$
    – Roman
    2 hours ago










  • $begingroup$
    It really depends on equations you are solving.
    $endgroup$
    – Vsevolod A.
    39 mins ago
















1












$begingroup$


I need to solve some differential equations with a Dirac delta function. e.g. the source terms are like, $delta(x)$ and $partial_x delta(x)$.



Could I just use the Gaussian type function? e.g.



$$ delta(x-a) = frac{a_1}{sqrt{pi}}exp(-frac{(x-a)^2}{a_1}),$$ and,
$$ partial_x delta(x-a) = - frac{2}{sqrt{pi}}(x-a)exp(-frac{(x-a)^2}{a_1}) $$



where by setting e.g. $a_1=0.01$.



If the answer is yes, then how to choose the reasonable values of $a_1$ and $a_2$?



Thanks!










share|improve this question









$endgroup$








  • 2




    $begingroup$
    While this is an interesting (and hard) question, I think it's more suitable for math.stackexchange.com or scicomp.stackexchange.com
    $endgroup$
    – xzczd
    5 hours ago












  • $begingroup$
    What is your $a_2$?
    $endgroup$
    – Roman
    2 hours ago










  • $begingroup$
    It really depends on equations you are solving.
    $endgroup$
    – Vsevolod A.
    39 mins ago














1












1








1





$begingroup$


I need to solve some differential equations with a Dirac delta function. e.g. the source terms are like, $delta(x)$ and $partial_x delta(x)$.



Could I just use the Gaussian type function? e.g.



$$ delta(x-a) = frac{a_1}{sqrt{pi}}exp(-frac{(x-a)^2}{a_1}),$$ and,
$$ partial_x delta(x-a) = - frac{2}{sqrt{pi}}(x-a)exp(-frac{(x-a)^2}{a_1}) $$



where by setting e.g. $a_1=0.01$.



If the answer is yes, then how to choose the reasonable values of $a_1$ and $a_2$?



Thanks!










share|improve this question









$endgroup$




I need to solve some differential equations with a Dirac delta function. e.g. the source terms are like, $delta(x)$ and $partial_x delta(x)$.



Could I just use the Gaussian type function? e.g.



$$ delta(x-a) = frac{a_1}{sqrt{pi}}exp(-frac{(x-a)^2}{a_1}),$$ and,
$$ partial_x delta(x-a) = - frac{2}{sqrt{pi}}(x-a)exp(-frac{(x-a)^2}{a_1}) $$



where by setting e.g. $a_1=0.01$.



If the answer is yes, then how to choose the reasonable values of $a_1$ and $a_2$?



Thanks!







differential-equations






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 6 hours ago









MPHYKEKMPHYKEK

783




783








  • 2




    $begingroup$
    While this is an interesting (and hard) question, I think it's more suitable for math.stackexchange.com or scicomp.stackexchange.com
    $endgroup$
    – xzczd
    5 hours ago












  • $begingroup$
    What is your $a_2$?
    $endgroup$
    – Roman
    2 hours ago










  • $begingroup$
    It really depends on equations you are solving.
    $endgroup$
    – Vsevolod A.
    39 mins ago














  • 2




    $begingroup$
    While this is an interesting (and hard) question, I think it's more suitable for math.stackexchange.com or scicomp.stackexchange.com
    $endgroup$
    – xzczd
    5 hours ago












  • $begingroup$
    What is your $a_2$?
    $endgroup$
    – Roman
    2 hours ago










  • $begingroup$
    It really depends on equations you are solving.
    $endgroup$
    – Vsevolod A.
    39 mins ago








2




2




$begingroup$
While this is an interesting (and hard) question, I think it's more suitable for math.stackexchange.com or scicomp.stackexchange.com
$endgroup$
– xzczd
5 hours ago






$begingroup$
While this is an interesting (and hard) question, I think it's more suitable for math.stackexchange.com or scicomp.stackexchange.com
$endgroup$
– xzczd
5 hours ago














$begingroup$
What is your $a_2$?
$endgroup$
– Roman
2 hours ago




$begingroup$
What is your $a_2$?
$endgroup$
– Roman
2 hours ago












$begingroup$
It really depends on equations you are solving.
$endgroup$
– Vsevolod A.
39 mins ago




$begingroup$
It really depends on equations you are solving.
$endgroup$
– Vsevolod A.
39 mins ago










3 Answers
3






active

oldest

votes


















2












$begingroup$

You can use a number of approximations. For example, the following three are quite often used.



diracDeltaLorentz[x_, eps_] := (eps/Pi)*(1/(x^2 + eps^2))
diracDeltaGauss[x_, eps_] := (1/(eps*Sqrt[Pi]))*Exp[-x^2/eps^2]
diracDeltaSin[x_, eps_] := (1/(Pi))*Sin[x/eps]/x

Plot[Evaluate[
Table[diracDeltaLorentz[x, i], {i, {1/2, 1, 2}}]],
{x, -4, 4},
PlotRange -> All, PlotStyle -> {Red, Green, Blue}]


enter image description here



Plot[Evaluate[
Table[diracDeltaGauss[x, i], {i, {1/2, 1, 2}}]],
{x, -4, 4}, PlotRange -> All,
PlotStyle -> {Red, Green, Blue}]


enter image description here



Plot[Evaluate[
Table[diracDeltaSin[x, i], {i, {1/2, 1, 2}}]],
{x, -4, 4}, PlotRange -> All,
PlotStyle -> {Red, Green, Blue}]


enter image description here



Of course, not all definitions are equivalent or well suited for integration with the given function. For example, let’s take



d1G = diracDeltaGauss[(x - 
a*t^2/2) + (1/(2 a))*(v - a*t)^2, ϵ1]


and



d2G = diracDeltaGauss[(v - a*t) + a*(t - t0), ϵ2]


Then you can compute the integrals



 xIntDiracDeltaG = 
Integrate[x*d1G*d2G, {x, -Infinity, Infinity},
Assumptions -> {Element[{a, v, t}, Reals],
ϵ1 > 0, ϵ2 > 0}]

(*Out:
(E^(-((-a t0 + v)^2/ϵ2^2)) (2 a t -
v) v)/(2 a Sqrt[π] ϵ2)
*)


and then



xvIntDiracDeltaG = 
Integrate[xIntDiracDeltaG, {v, -Infinity, Infinity},
Assumptions -> {Element[{a, v, t, t0}, Reals],
ϵ1 > 0, ϵ2 > 0}]

(*Out: a t t0 - (2 a^2 t0^2 + ϵ2^2)/(4 a) *)


However if you define similar functions using the definitions of diracDeltaLorentz and diracDeltaSin above and then try to repeat computation of the same integrals, you will notice that the integrals do not converge. So, the particular choice of a diracDelta "model" depends on the functions you want to integrate.






share|improve this answer











$endgroup$





















    2












    $begingroup$

    If you need infinite differentiability, then I think a Gaussian is a good choice. For choosing parameters the parameterization given on https://en.wikipedia.org/wiki/Gaussian_function in terms of the width $sigma$ is easier:



    g[{μ_, σ_}, x_] = E^(-((x-μ)/σ)^2/2)/(σ*Sqrt[2π]);
    dg[{μ_, σ_}, x_] = D[g[{μ, σ}, x], x];


    Choose $sigma$ smaller than any feature of your other functions.



    Alternatively, if you only need first derivatives you could use a triangle function, this may be even simpler:



    t[{μ_, σ_}, x_] = Piecewise[{{1/σ (1 + (x - μ)/σ), μ - σ < x < μ},
    {1/σ (1 - (x - μ)/σ), μ < x < μ + σ}}];
    dt[{μ_, σ_}, x_] = D[t[{μ, σ}, x], x];


    Again, choose the width $sigma$ smaller than any feature of your other functions.



    Usually the Dirac $delta$-function is defined with $mu=0$ in the above expressions (it is centered at the origin).






    share|improve this answer











    $endgroup$













    • $begingroup$
      It is not so simple because the Gaussian type function tends to the $delta$-function in the weak topology (see en.wikipedia.org/wiki/Weak_topology for info).
      $endgroup$
      – user64494
      5 hours ago










    • $begingroup$
      Thanks @user64494, in physics we get lazy about these things, sorry.
      $endgroup$
      – Roman
      2 hours ago










    • $begingroup$
      But such an easy approach leads to wrong results in some cases. See en.wikipedia.org/wiki/Dirac_delta_function for info.
      $endgroup$
      – user64494
      1 hour ago






    • 2




      $begingroup$
      @user64494 If the detailed form of your approximation to the delta function matters in a physical calculation, you need to revisit your physics. When we use a delta function, we mean "the impulse is so narrow that its form doesn't matter here". The cases you're worried about are precisely the cases where you shouldn't use a delta in the first place.
      $endgroup$
      – John Doty
      1 hour ago










    • $begingroup$
      @John Doty: Loking in your questions and answers, I see neither physics nor distributions.
      $endgroup$
      – user64494
      55 mins ago





















    0












    $begingroup$

    DSolve can often handle DiracDeltas directly, without resorting to numerical or functional approximations. For example:



    DSolve[y'[x] + 7 y[x] == DiracDelta[x] + D[DiracDelta[x], x], y[x], x]


    provides a nice closed form solution.





    share









    $endgroup$













      Your Answer





      StackExchange.ifUsing("editor", function () {
      return StackExchange.using("mathjaxEditing", function () {
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      });
      });
      }, "mathjax-editing");

      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
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192456%2fhow-to-deal-with-a-dirac-delta-function-numerically%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2












      $begingroup$

      You can use a number of approximations. For example, the following three are quite often used.



      diracDeltaLorentz[x_, eps_] := (eps/Pi)*(1/(x^2 + eps^2))
      diracDeltaGauss[x_, eps_] := (1/(eps*Sqrt[Pi]))*Exp[-x^2/eps^2]
      diracDeltaSin[x_, eps_] := (1/(Pi))*Sin[x/eps]/x

      Plot[Evaluate[
      Table[diracDeltaLorentz[x, i], {i, {1/2, 1, 2}}]],
      {x, -4, 4},
      PlotRange -> All, PlotStyle -> {Red, Green, Blue}]


      enter image description here



      Plot[Evaluate[
      Table[diracDeltaGauss[x, i], {i, {1/2, 1, 2}}]],
      {x, -4, 4}, PlotRange -> All,
      PlotStyle -> {Red, Green, Blue}]


      enter image description here



      Plot[Evaluate[
      Table[diracDeltaSin[x, i], {i, {1/2, 1, 2}}]],
      {x, -4, 4}, PlotRange -> All,
      PlotStyle -> {Red, Green, Blue}]


      enter image description here



      Of course, not all definitions are equivalent or well suited for integration with the given function. For example, let’s take



      d1G = diracDeltaGauss[(x - 
      a*t^2/2) + (1/(2 a))*(v - a*t)^2, ϵ1]


      and



      d2G = diracDeltaGauss[(v - a*t) + a*(t - t0), ϵ2]


      Then you can compute the integrals



       xIntDiracDeltaG = 
      Integrate[x*d1G*d2G, {x, -Infinity, Infinity},
      Assumptions -> {Element[{a, v, t}, Reals],
      ϵ1 > 0, ϵ2 > 0}]

      (*Out:
      (E^(-((-a t0 + v)^2/ϵ2^2)) (2 a t -
      v) v)/(2 a Sqrt[π] ϵ2)
      *)


      and then



      xvIntDiracDeltaG = 
      Integrate[xIntDiracDeltaG, {v, -Infinity, Infinity},
      Assumptions -> {Element[{a, v, t, t0}, Reals],
      ϵ1 > 0, ϵ2 > 0}]

      (*Out: a t t0 - (2 a^2 t0^2 + ϵ2^2)/(4 a) *)


      However if you define similar functions using the definitions of diracDeltaLorentz and diracDeltaSin above and then try to repeat computation of the same integrals, you will notice that the integrals do not converge. So, the particular choice of a diracDelta "model" depends on the functions you want to integrate.






      share|improve this answer











      $endgroup$


















        2












        $begingroup$

        You can use a number of approximations. For example, the following three are quite often used.



        diracDeltaLorentz[x_, eps_] := (eps/Pi)*(1/(x^2 + eps^2))
        diracDeltaGauss[x_, eps_] := (1/(eps*Sqrt[Pi]))*Exp[-x^2/eps^2]
        diracDeltaSin[x_, eps_] := (1/(Pi))*Sin[x/eps]/x

        Plot[Evaluate[
        Table[diracDeltaLorentz[x, i], {i, {1/2, 1, 2}}]],
        {x, -4, 4},
        PlotRange -> All, PlotStyle -> {Red, Green, Blue}]


        enter image description here



        Plot[Evaluate[
        Table[diracDeltaGauss[x, i], {i, {1/2, 1, 2}}]],
        {x, -4, 4}, PlotRange -> All,
        PlotStyle -> {Red, Green, Blue}]


        enter image description here



        Plot[Evaluate[
        Table[diracDeltaSin[x, i], {i, {1/2, 1, 2}}]],
        {x, -4, 4}, PlotRange -> All,
        PlotStyle -> {Red, Green, Blue}]


        enter image description here



        Of course, not all definitions are equivalent or well suited for integration with the given function. For example, let’s take



        d1G = diracDeltaGauss[(x - 
        a*t^2/2) + (1/(2 a))*(v - a*t)^2, ϵ1]


        and



        d2G = diracDeltaGauss[(v - a*t) + a*(t - t0), ϵ2]


        Then you can compute the integrals



         xIntDiracDeltaG = 
        Integrate[x*d1G*d2G, {x, -Infinity, Infinity},
        Assumptions -> {Element[{a, v, t}, Reals],
        ϵ1 > 0, ϵ2 > 0}]

        (*Out:
        (E^(-((-a t0 + v)^2/ϵ2^2)) (2 a t -
        v) v)/(2 a Sqrt[π] ϵ2)
        *)


        and then



        xvIntDiracDeltaG = 
        Integrate[xIntDiracDeltaG, {v, -Infinity, Infinity},
        Assumptions -> {Element[{a, v, t, t0}, Reals],
        ϵ1 > 0, ϵ2 > 0}]

        (*Out: a t t0 - (2 a^2 t0^2 + ϵ2^2)/(4 a) *)


        However if you define similar functions using the definitions of diracDeltaLorentz and diracDeltaSin above and then try to repeat computation of the same integrals, you will notice that the integrals do not converge. So, the particular choice of a diracDelta "model" depends on the functions you want to integrate.






        share|improve this answer











        $endgroup$
















          2












          2








          2





          $begingroup$

          You can use a number of approximations. For example, the following three are quite often used.



          diracDeltaLorentz[x_, eps_] := (eps/Pi)*(1/(x^2 + eps^2))
          diracDeltaGauss[x_, eps_] := (1/(eps*Sqrt[Pi]))*Exp[-x^2/eps^2]
          diracDeltaSin[x_, eps_] := (1/(Pi))*Sin[x/eps]/x

          Plot[Evaluate[
          Table[diracDeltaLorentz[x, i], {i, {1/2, 1, 2}}]],
          {x, -4, 4},
          PlotRange -> All, PlotStyle -> {Red, Green, Blue}]


          enter image description here



          Plot[Evaluate[
          Table[diracDeltaGauss[x, i], {i, {1/2, 1, 2}}]],
          {x, -4, 4}, PlotRange -> All,
          PlotStyle -> {Red, Green, Blue}]


          enter image description here



          Plot[Evaluate[
          Table[diracDeltaSin[x, i], {i, {1/2, 1, 2}}]],
          {x, -4, 4}, PlotRange -> All,
          PlotStyle -> {Red, Green, Blue}]


          enter image description here



          Of course, not all definitions are equivalent or well suited for integration with the given function. For example, let’s take



          d1G = diracDeltaGauss[(x - 
          a*t^2/2) + (1/(2 a))*(v - a*t)^2, ϵ1]


          and



          d2G = diracDeltaGauss[(v - a*t) + a*(t - t0), ϵ2]


          Then you can compute the integrals



           xIntDiracDeltaG = 
          Integrate[x*d1G*d2G, {x, -Infinity, Infinity},
          Assumptions -> {Element[{a, v, t}, Reals],
          ϵ1 > 0, ϵ2 > 0}]

          (*Out:
          (E^(-((-a t0 + v)^2/ϵ2^2)) (2 a t -
          v) v)/(2 a Sqrt[π] ϵ2)
          *)


          and then



          xvIntDiracDeltaG = 
          Integrate[xIntDiracDeltaG, {v, -Infinity, Infinity},
          Assumptions -> {Element[{a, v, t, t0}, Reals],
          ϵ1 > 0, ϵ2 > 0}]

          (*Out: a t t0 - (2 a^2 t0^2 + ϵ2^2)/(4 a) *)


          However if you define similar functions using the definitions of diracDeltaLorentz and diracDeltaSin above and then try to repeat computation of the same integrals, you will notice that the integrals do not converge. So, the particular choice of a diracDelta "model" depends on the functions you want to integrate.






          share|improve this answer











          $endgroup$



          You can use a number of approximations. For example, the following three are quite often used.



          diracDeltaLorentz[x_, eps_] := (eps/Pi)*(1/(x^2 + eps^2))
          diracDeltaGauss[x_, eps_] := (1/(eps*Sqrt[Pi]))*Exp[-x^2/eps^2]
          diracDeltaSin[x_, eps_] := (1/(Pi))*Sin[x/eps]/x

          Plot[Evaluate[
          Table[diracDeltaLorentz[x, i], {i, {1/2, 1, 2}}]],
          {x, -4, 4},
          PlotRange -> All, PlotStyle -> {Red, Green, Blue}]


          enter image description here



          Plot[Evaluate[
          Table[diracDeltaGauss[x, i], {i, {1/2, 1, 2}}]],
          {x, -4, 4}, PlotRange -> All,
          PlotStyle -> {Red, Green, Blue}]


          enter image description here



          Plot[Evaluate[
          Table[diracDeltaSin[x, i], {i, {1/2, 1, 2}}]],
          {x, -4, 4}, PlotRange -> All,
          PlotStyle -> {Red, Green, Blue}]


          enter image description here



          Of course, not all definitions are equivalent or well suited for integration with the given function. For example, let’s take



          d1G = diracDeltaGauss[(x - 
          a*t^2/2) + (1/(2 a))*(v - a*t)^2, ϵ1]


          and



          d2G = diracDeltaGauss[(v - a*t) + a*(t - t0), ϵ2]


          Then you can compute the integrals



           xIntDiracDeltaG = 
          Integrate[x*d1G*d2G, {x, -Infinity, Infinity},
          Assumptions -> {Element[{a, v, t}, Reals],
          ϵ1 > 0, ϵ2 > 0}]

          (*Out:
          (E^(-((-a t0 + v)^2/ϵ2^2)) (2 a t -
          v) v)/(2 a Sqrt[π] ϵ2)
          *)


          and then



          xvIntDiracDeltaG = 
          Integrate[xIntDiracDeltaG, {v, -Infinity, Infinity},
          Assumptions -> {Element[{a, v, t, t0}, Reals],
          ϵ1 > 0, ϵ2 > 0}]

          (*Out: a t t0 - (2 a^2 t0^2 + ϵ2^2)/(4 a) *)


          However if you define similar functions using the definitions of diracDeltaLorentz and diracDeltaSin above and then try to repeat computation of the same integrals, you will notice that the integrals do not converge. So, the particular choice of a diracDelta "model" depends on the functions you want to integrate.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 46 mins ago









          MarcoB

          36.4k556112




          36.4k556112










          answered 1 hour ago









          user18792user18792

          1,728915




          1,728915























              2












              $begingroup$

              If you need infinite differentiability, then I think a Gaussian is a good choice. For choosing parameters the parameterization given on https://en.wikipedia.org/wiki/Gaussian_function in terms of the width $sigma$ is easier:



              g[{μ_, σ_}, x_] = E^(-((x-μ)/σ)^2/2)/(σ*Sqrt[2π]);
              dg[{μ_, σ_}, x_] = D[g[{μ, σ}, x], x];


              Choose $sigma$ smaller than any feature of your other functions.



              Alternatively, if you only need first derivatives you could use a triangle function, this may be even simpler:



              t[{μ_, σ_}, x_] = Piecewise[{{1/σ (1 + (x - μ)/σ), μ - σ < x < μ},
              {1/σ (1 - (x - μ)/σ), μ < x < μ + σ}}];
              dt[{μ_, σ_}, x_] = D[t[{μ, σ}, x], x];


              Again, choose the width $sigma$ smaller than any feature of your other functions.



              Usually the Dirac $delta$-function is defined with $mu=0$ in the above expressions (it is centered at the origin).






              share|improve this answer











              $endgroup$













              • $begingroup$
                It is not so simple because the Gaussian type function tends to the $delta$-function in the weak topology (see en.wikipedia.org/wiki/Weak_topology for info).
                $endgroup$
                – user64494
                5 hours ago










              • $begingroup$
                Thanks @user64494, in physics we get lazy about these things, sorry.
                $endgroup$
                – Roman
                2 hours ago










              • $begingroup$
                But such an easy approach leads to wrong results in some cases. See en.wikipedia.org/wiki/Dirac_delta_function for info.
                $endgroup$
                – user64494
                1 hour ago






              • 2




                $begingroup$
                @user64494 If the detailed form of your approximation to the delta function matters in a physical calculation, you need to revisit your physics. When we use a delta function, we mean "the impulse is so narrow that its form doesn't matter here". The cases you're worried about are precisely the cases where you shouldn't use a delta in the first place.
                $endgroup$
                – John Doty
                1 hour ago










              • $begingroup$
                @John Doty: Loking in your questions and answers, I see neither physics nor distributions.
                $endgroup$
                – user64494
                55 mins ago


















              2












              $begingroup$

              If you need infinite differentiability, then I think a Gaussian is a good choice. For choosing parameters the parameterization given on https://en.wikipedia.org/wiki/Gaussian_function in terms of the width $sigma$ is easier:



              g[{μ_, σ_}, x_] = E^(-((x-μ)/σ)^2/2)/(σ*Sqrt[2π]);
              dg[{μ_, σ_}, x_] = D[g[{μ, σ}, x], x];


              Choose $sigma$ smaller than any feature of your other functions.



              Alternatively, if you only need first derivatives you could use a triangle function, this may be even simpler:



              t[{μ_, σ_}, x_] = Piecewise[{{1/σ (1 + (x - μ)/σ), μ - σ < x < μ},
              {1/σ (1 - (x - μ)/σ), μ < x < μ + σ}}];
              dt[{μ_, σ_}, x_] = D[t[{μ, σ}, x], x];


              Again, choose the width $sigma$ smaller than any feature of your other functions.



              Usually the Dirac $delta$-function is defined with $mu=0$ in the above expressions (it is centered at the origin).






              share|improve this answer











              $endgroup$













              • $begingroup$
                It is not so simple because the Gaussian type function tends to the $delta$-function in the weak topology (see en.wikipedia.org/wiki/Weak_topology for info).
                $endgroup$
                – user64494
                5 hours ago










              • $begingroup$
                Thanks @user64494, in physics we get lazy about these things, sorry.
                $endgroup$
                – Roman
                2 hours ago










              • $begingroup$
                But such an easy approach leads to wrong results in some cases. See en.wikipedia.org/wiki/Dirac_delta_function for info.
                $endgroup$
                – user64494
                1 hour ago






              • 2




                $begingroup$
                @user64494 If the detailed form of your approximation to the delta function matters in a physical calculation, you need to revisit your physics. When we use a delta function, we mean "the impulse is so narrow that its form doesn't matter here". The cases you're worried about are precisely the cases where you shouldn't use a delta in the first place.
                $endgroup$
                – John Doty
                1 hour ago










              • $begingroup$
                @John Doty: Loking in your questions and answers, I see neither physics nor distributions.
                $endgroup$
                – user64494
                55 mins ago
















              2












              2








              2





              $begingroup$

              If you need infinite differentiability, then I think a Gaussian is a good choice. For choosing parameters the parameterization given on https://en.wikipedia.org/wiki/Gaussian_function in terms of the width $sigma$ is easier:



              g[{μ_, σ_}, x_] = E^(-((x-μ)/σ)^2/2)/(σ*Sqrt[2π]);
              dg[{μ_, σ_}, x_] = D[g[{μ, σ}, x], x];


              Choose $sigma$ smaller than any feature of your other functions.



              Alternatively, if you only need first derivatives you could use a triangle function, this may be even simpler:



              t[{μ_, σ_}, x_] = Piecewise[{{1/σ (1 + (x - μ)/σ), μ - σ < x < μ},
              {1/σ (1 - (x - μ)/σ), μ < x < μ + σ}}];
              dt[{μ_, σ_}, x_] = D[t[{μ, σ}, x], x];


              Again, choose the width $sigma$ smaller than any feature of your other functions.



              Usually the Dirac $delta$-function is defined with $mu=0$ in the above expressions (it is centered at the origin).






              share|improve this answer











              $endgroup$



              If you need infinite differentiability, then I think a Gaussian is a good choice. For choosing parameters the parameterization given on https://en.wikipedia.org/wiki/Gaussian_function in terms of the width $sigma$ is easier:



              g[{μ_, σ_}, x_] = E^(-((x-μ)/σ)^2/2)/(σ*Sqrt[2π]);
              dg[{μ_, σ_}, x_] = D[g[{μ, σ}, x], x];


              Choose $sigma$ smaller than any feature of your other functions.



              Alternatively, if you only need first derivatives you could use a triangle function, this may be even simpler:



              t[{μ_, σ_}, x_] = Piecewise[{{1/σ (1 + (x - μ)/σ), μ - σ < x < μ},
              {1/σ (1 - (x - μ)/σ), μ < x < μ + σ}}];
              dt[{μ_, σ_}, x_] = D[t[{μ, σ}, x], x];


              Again, choose the width $sigma$ smaller than any feature of your other functions.



              Usually the Dirac $delta$-function is defined with $mu=0$ in the above expressions (it is centered at the origin).







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited 4 mins ago

























              answered 5 hours ago









              RomanRoman

              2,249716




              2,249716












              • $begingroup$
                It is not so simple because the Gaussian type function tends to the $delta$-function in the weak topology (see en.wikipedia.org/wiki/Weak_topology for info).
                $endgroup$
                – user64494
                5 hours ago










              • $begingroup$
                Thanks @user64494, in physics we get lazy about these things, sorry.
                $endgroup$
                – Roman
                2 hours ago










              • $begingroup$
                But such an easy approach leads to wrong results in some cases. See en.wikipedia.org/wiki/Dirac_delta_function for info.
                $endgroup$
                – user64494
                1 hour ago






              • 2




                $begingroup$
                @user64494 If the detailed form of your approximation to the delta function matters in a physical calculation, you need to revisit your physics. When we use a delta function, we mean "the impulse is so narrow that its form doesn't matter here". The cases you're worried about are precisely the cases where you shouldn't use a delta in the first place.
                $endgroup$
                – John Doty
                1 hour ago










              • $begingroup$
                @John Doty: Loking in your questions and answers, I see neither physics nor distributions.
                $endgroup$
                – user64494
                55 mins ago




















              • $begingroup$
                It is not so simple because the Gaussian type function tends to the $delta$-function in the weak topology (see en.wikipedia.org/wiki/Weak_topology for info).
                $endgroup$
                – user64494
                5 hours ago










              • $begingroup$
                Thanks @user64494, in physics we get lazy about these things, sorry.
                $endgroup$
                – Roman
                2 hours ago










              • $begingroup$
                But such an easy approach leads to wrong results in some cases. See en.wikipedia.org/wiki/Dirac_delta_function for info.
                $endgroup$
                – user64494
                1 hour ago






              • 2




                $begingroup$
                @user64494 If the detailed form of your approximation to the delta function matters in a physical calculation, you need to revisit your physics. When we use a delta function, we mean "the impulse is so narrow that its form doesn't matter here". The cases you're worried about are precisely the cases where you shouldn't use a delta in the first place.
                $endgroup$
                – John Doty
                1 hour ago










              • $begingroup$
                @John Doty: Loking in your questions and answers, I see neither physics nor distributions.
                $endgroup$
                – user64494
                55 mins ago


















              $begingroup$
              It is not so simple because the Gaussian type function tends to the $delta$-function in the weak topology (see en.wikipedia.org/wiki/Weak_topology for info).
              $endgroup$
              – user64494
              5 hours ago




              $begingroup$
              It is not so simple because the Gaussian type function tends to the $delta$-function in the weak topology (see en.wikipedia.org/wiki/Weak_topology for info).
              $endgroup$
              – user64494
              5 hours ago












              $begingroup$
              Thanks @user64494, in physics we get lazy about these things, sorry.
              $endgroup$
              – Roman
              2 hours ago




              $begingroup$
              Thanks @user64494, in physics we get lazy about these things, sorry.
              $endgroup$
              – Roman
              2 hours ago












              $begingroup$
              But such an easy approach leads to wrong results in some cases. See en.wikipedia.org/wiki/Dirac_delta_function for info.
              $endgroup$
              – user64494
              1 hour ago




              $begingroup$
              But such an easy approach leads to wrong results in some cases. See en.wikipedia.org/wiki/Dirac_delta_function for info.
              $endgroup$
              – user64494
              1 hour ago




              2




              2




              $begingroup$
              @user64494 If the detailed form of your approximation to the delta function matters in a physical calculation, you need to revisit your physics. When we use a delta function, we mean "the impulse is so narrow that its form doesn't matter here". The cases you're worried about are precisely the cases where you shouldn't use a delta in the first place.
              $endgroup$
              – John Doty
              1 hour ago




              $begingroup$
              @user64494 If the detailed form of your approximation to the delta function matters in a physical calculation, you need to revisit your physics. When we use a delta function, we mean "the impulse is so narrow that its form doesn't matter here". The cases you're worried about are precisely the cases where you shouldn't use a delta in the first place.
              $endgroup$
              – John Doty
              1 hour ago












              $begingroup$
              @John Doty: Loking in your questions and answers, I see neither physics nor distributions.
              $endgroup$
              – user64494
              55 mins ago






              $begingroup$
              @John Doty: Loking in your questions and answers, I see neither physics nor distributions.
              $endgroup$
              – user64494
              55 mins ago













              0












              $begingroup$

              DSolve can often handle DiracDeltas directly, without resorting to numerical or functional approximations. For example:



              DSolve[y'[x] + 7 y[x] == DiracDelta[x] + D[DiracDelta[x], x], y[x], x]


              provides a nice closed form solution.





              share









              $endgroup$


















                0












                $begingroup$

                DSolve can often handle DiracDeltas directly, without resorting to numerical or functional approximations. For example:



                DSolve[y'[x] + 7 y[x] == DiracDelta[x] + D[DiracDelta[x], x], y[x], x]


                provides a nice closed form solution.





                share









                $endgroup$
















                  0












                  0








                  0





                  $begingroup$

                  DSolve can often handle DiracDeltas directly, without resorting to numerical or functional approximations. For example:



                  DSolve[y'[x] + 7 y[x] == DiracDelta[x] + D[DiracDelta[x], x], y[x], x]


                  provides a nice closed form solution.





                  share









                  $endgroup$



                  DSolve can often handle DiracDeltas directly, without resorting to numerical or functional approximations. For example:



                  DSolve[y'[x] + 7 y[x] == DiracDelta[x] + D[DiracDelta[x], x], y[x], x]


                  provides a nice closed form solution.






                  share











                  share


                  share










                  answered 9 mins ago









                  bill sbill s

                  53.6k376153




                  53.6k376153






























                      draft saved

                      draft discarded




















































                      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%2f192456%2fhow-to-deal-with-a-dirac-delta-function-numerically%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

                      Fairchild Swearingen Metro Inhaltsverzeichnis Geschichte | Innenausstattung | Nutzung | Zwischenfälle...

                      Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...

                      Marineschifffahrtleitung Inhaltsverzeichnis Geschichte | Heutige Organisation der NATO | Nationale und...