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.Thu, 10 Jun 2021 13:16:52 +0200Lazy evaluation of symbolic integrationhttps://ask.sagemath.org/question/57529/lazy-evaluation-of-symbolic-integration/I am confused by the output for the following code
var('x,u,w')
F(x)=integral((min_symbolic(u,0)-1/2)*exp(x*u),u,-1,1)
G(x)=F(x)
H(w)=F(w)
print("F:",F)
print("G:",G)
print("H:",H)
The output I am getting is
F: x |--> 1/2*integrate((2*min(0, u) - 1)*e^(u*x), u, -1, 1)
G: x |--> 1/2*integrate((2*min(0, u) - 1)*e^(u*x), u, -1, 1)
H: w |--> 1/2*(3*w*e^(-w) + 2*e^(-w) - 1)/w^2 - 1/2*(w*e^w + 1)/w^2
The output for H is what I am actually after, but I am wondering why it is different from the output for F and G, whether this is the intended behaviour and what is the official way to influence the evaluation/non-evaluation of such a symbolic integral expression.
Also this behaviour must have changed at some point in the recent past, breaking some of my existing code as a result.ibykusThu, 10 Jun 2021 13:16:52 +0200https://ask.sagemath.org/question/57529/Late binding and lazy symbolic thence numeric mathhttps://ask.sagemath.org/question/30833/late-binding-and-lazy-symbolic-thence-numeric-math/Being a newbie to Sage, after growing weary of wxMaxima, perhaps this is already supported but bear with me...
It seems the programming principle of "late binding" should apply, in particular, to systems in which numeric and symbolic math are seamlessly integrated.
For example, let's say I:
from scipy.constants import epsilon_0, c
...define an identity like:
mu_0*epsilon_0=1/c^2
...and then define a function, say, for the vector potential of a Hertzian dipole:
norm(x,y,z)=sqrt(x*x+y*y+z*z)
Idipole(t)=I0*cos(omega*t)
A(x,y,z,t)=[0,0,(1/(4*pi*epsilon_0*c^2)*L*Idipole(t-norm(x,y,z)/c)/norm(x,y,z))]
If (after defining other symbols) I then demand a numeric value, say, in a plot:
plot(A(0,0,z,0),z,1,4)
It should be able to, in service of this demand, lazily invoke an optimization by first solving for mu_0 thence symbolic simplification to:
A(x,y,z,t)=[0,0,(mu_0/(4*pi)*L*Idipole(t-norm(x,y,z)/c)/norm(x,y,z))]
...prior to substituting numeric values or other presumptive substitutions.
Is this kind of late binding with lazy symbolic thence numeric math supported by Sage?
jaboweryWed, 18 Nov 2015 22:10:31 +0100https://ask.sagemath.org/question/30833/