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.Mon, 12 Apr 2021 06:19:54 +0200Is there a way to compute the "correct" distributional answer, -4*pi*dirac_delta(r), as the Laplacian of 1/r (in spherical coordinates on Euclidean space)?https://ask.sagemath.org/question/56621/is-there-a-way-to-compute-the-correct-distributional-answer-4pidirac_deltar-as-the-laplacian-of-1r-in-spherical-coordinates-on-euclidean-space/**Background:** I'm putting together an EM notebook for educational purposes, and would like to be able to show demonstrations of Gauss's Law (for example). However, for completely understandable and obvious reasons, integrating `(1/r^2*r_hat).div()` over the unit ball just gives `0`. Computing the flux of `(1/r^2*r_hat)` through the unit sphere gives the expected result, of course, but I'd hoped to directly demonstrate that it's proportional to the volume integral.perfectly_oddMon, 12 Apr 2021 06:19:54 +0200https://ask.sagemath.org/question/56621/Divergence of inverse squarehttps://ask.sagemath.org/question/55608/divergence-of-inverse-square/ Hello,
I tried to calculate the divergence of 1/r^2*e_r, but I got zero, where it should have been 4*pi*dirac_delta(r*e_r)
E.<r,th,ph>=EuclideanSpace(coordinates="spherical")
v=E.vector_field([1/r^2,0,0])
v.div().display()
Results is
E^3 --> R
(r, th, ph) |--> 0
Can this be considered as a bug?
curios_mindSun, 07 Feb 2021 00:15:43 +0100https://ask.sagemath.org/question/55608/Another: dirac_delta integration: possible bug?https://ask.sagemath.org/question/52117/another-dirac_delta-integration-possible-bug/I think there is another problem with the integration of the dirac_delta in Sage:
(previous problem is discussed in the thread [Integration of dirac_delta](https://ask.sagemath.org/question/52088/integration-of-dirac_delta/))
Here is the problem:
var('a',"real")
f=integral(dirac_delta(a*x),x,-oo,oo);show(f)
returns `1` where it should return `1/|a|`
and
var('a',"real")
f=integral(dirac_delta(x^2-a^2),x,-oo,oo);show(f)
returns `1/|a|`, where it should be `1/(2|a|)`curios_mindFri, 19 Jun 2020 23:54:08 +0200https://ask.sagemath.org/question/52117/Integration of dirac_deltahttps://ask.sagemath.org/question/52088/integration-of-dirac_delta/Hello,
When I tried to integrate the following
(dirac_delta(x)).integrate(x,-pi,pi)
I get `1` (as expected)
But when I integrate
(dirac_delta(cos(x))).integrate(x,-pi,pi)
I get `integrate(dirac_delta(cos(x)), x, -pi, pi)` back. I would expect to get `2` since there are two points which are zero between the upper and lower bounds of the integral. So by any means of approaching these points with limit during the integration, the integral of dirac_delta should have returned 1 for each point which adds up to 2
If I try the same with Mathematica,
Integrate[DiracDelta[x], {x, -Pi, Pi}]
I get `1`
and when I try
Integrate[DiracDelta[Cos[x]], {x, -Pi, Pi}]
I get `2` as I would expect.
What is the reason of this behaviour of Sage?curios_mindFri, 19 Jun 2020 13:43:53 +0200https://ask.sagemath.org/question/52088/How to simplify dirac_delta?https://ask.sagemath.org/question/51779/how-to-simplify-dirac_delta/Various manipulations are possible with `dirac_delta` and its derivatives. How can I teach sage to simplify these? For example, the following Green's function for a free particle in 1D could simplify to simply `dirac_delta(x)`:
sage: var('x,k')
sage: G = heaviside(x)*sin(k*x)/k
sage: simplify(k**2*G + diff(G, x, x))
2*cos(k*x)*dirac_delta(x) + sin(k*x)*diff(dirac_delta(x), x)/k
How can I teach sage to perform the following simplifications
f(x)*dirac_delta(x)
-> f(0)*dirac_delta(x)
f(x)*diff(dirac_delta(x),x)
-> diff(f(x), x)*dirac_delta(x)
-> diff(f(x), x).subs(x=0)*dirac_delta(x)
which would bring the answer into the desired form `dirac_delta(x)`?mforbesSat, 06 Jun 2020 08:16:37 +0200https://ask.sagemath.org/question/51779/How can I Integrate the dirac_delta and heaviside functions in sage?https://ask.sagemath.org/question/8041/how-can-i-integrate-the-dirac_delta-and-heaviside-functions-in-sage/Is it possible to integrate the dirac_delta and the heaviside function in sage. I can't seem to do it. For the dirac_delta I've tried the following code:
reset()
var('x,a')
integral(x^2*dirac_delta(-a + x), x, -infinity, +infinity)
from which, after evaluating, I get:
integrate(x^2*dirac_delta(-a + x), x, -Infinity, +Infinity)
i.e. the integration is not performed. I am expecting a^2.
For the heaviside fucntion I've tried:
reset()
var('x,x1,x2')
k(x,x1,x2)=heaviside(x-x1)*heaviside(x2-x)
integrate(k(x,x1,x2),x,-infinity,infinity)
from which, after evaluating, I get:
integrate(heaviside(-x + x2)*heaviside(x - x1), x, -Infinity, +Infinity)
I am expecting x2-x1. Am I doing something wrong or is it just not possible to do these integrations in sage?rtrwalkerThu, 31 Mar 2011 20:56:34 +0200https://ask.sagemath.org/question/8041/limit of function with dirac deltahttps://ask.sagemath.org/question/36876/limit-of-function-with-dirac-delta/Consider the following code:
sage.var(x)
f = (1-x) * sage.unit_step(x)
df = f.diff(x) -> -unit_step(x) + (1-x)*dirac_delta(x)
Trying to compute `df.limit(x=0, dir="right")`, which should return `-1`, but instead returns `limit(-unit_step(x) + (1-x)*dirac_delta(x), x, 0, plus)`.
Even `df.limit(x=0.5)` return `limit(-unit_step(x) + (1-x)*dirac_delta(x), x, 0.5)` instead of `-1`.
Any idea on what might be going on? Thanks!maaaaaaartinThu, 09 Mar 2017 12:15:01 +0100https://ask.sagemath.org/question/36876/