I'm trying to use this function
def mean(f):
r=sym.integrate(f,(t,0,0.02))
return r
where f
is
f1=t
x=t
x=sym.sin(2*pi*50*t)
f1=sym.sign(x)
And t
is:
t=Symbol('t')
When I run the program I get this:
Integral(Piecewise((1, sin(314.159265358979*t) > 0), (-1, sin(314.159265358979*t) < 0), (0, True)), (t, 0, 0.02))
Is there a way to get the numeric answer?
CodePudding user response:
That's happening because you are using pi
from a numerical package (I guess math
or numpy
). When using symbolic expressions, you should use pi
exposed by Sympy.
import sympy as sym
def mean(f):
r=sym.integrate(f,(t,0,0.02))
return r
t=Symbol('t')
x=sym.sin(2*sym.pi*50*t)
f1=sym.sign(x)
mean(f1)
# output: 0