I played with the dirac_delta function but didn't get the results that I
need.
In the end, I need to be able to plot and calculate functions that are
multiplied with a dirac comb like
http://upload.wikimedia.org/wikipedia/commons/6/6a/Dirac-comb_-_Sampling.png
But I didn't find out how to do it.
Does anybody know how to do this?
Thanks,
Tobi
I got a first result, but it only works when I "type" it in the command
line interface.
import numpy as np
import pylab as pl
pl.ion()
pl.grid(True)
var('t n_ ll ul')
tt=np.arange(0.01,10,0.01)
f=sin(t)/t
ts=0.5
fs=sum(f*dirac_delta(t-(2*n_-1)*ts),n_,0,20)/dirac_delta(0)
fl=lambda t:f
fl=fl(t)
fsl=lambda t:fs
fsl=fsl(t)
fslm=map(fsl,tt)
fsld=np.array(fslm)
fsld=map(n,fsld)
pl.vlines(tt,[0],fsld)
flm=map(fl,tt)
fld=np.array(flm)
fld=map(n,fld)
pl.plot(tt,fld,'--',linewidth=.5)
When I run it like
run -i file.py
I get an error:
AttributeError Traceback (most recent call last)
/media/daten/Diplomarbeit/Teilergebnisse/mathe/dirac_comb.py in <module>()
20 f=sin(t)/t
21 ts=0.5
---> 22 fs=sum(f*dirac_delta(t-(2*n_-1)*ts),n_,0,20)/dirac_delta(0)
23
24 fl=lambda t:f
/home/twk/Downloads/sage/local/lib/python2.6/site-packages/sage/misc/functional.pyc
in symbolic_sum(expression, *args, **kwds)
657 """
658 if hasattr(expression, 'sum'):
--> 659 return expression.sum(*args, **kwds)
660 elif len(args) <= 1:
661 return sum(expression, *args)
/home/twk/Downloads/sage/local/lib/python2.6/site-packages/sage/symbolic/expression.so
in sage.symbolic.expression.Expression.sum
(sage/symbolic/expression.cpp:28898)()
/home/twk/Downloads/sage/local/lib/python2.6/site-packages/sage/calculus/calculus.pyc
in symbolic_sum(expression, v, a, b, algorithm)
482
483 if algorithm == 'maxima':
--> 484 sum = "'sum(%s, %s, %s, %s)" %
tuple([repr(expr._maxima_()) for expr in (expression, v, a, b)])
485 try:
486 result = maxima.simplify_sum(sum)
AttributeError: 'int' object has no attribute '_maxima_'
How can I cast these integers to numbers or what is my mistake?
Is there a better way to do this?
Thanks,
Tobi
<snip>
> AttributeError: 'int' object has no attribute '_maxima_'
>
>
> How can I cast these integers to numbers or what is my mistake?
> Is there a better way to do this?
This looks like a bug in the way symbolic sums are handled:
http://trac.sagemath.org/sage_trac/ticket/9393
For a workaround, try renaming your file to have the extension .sage
instead of .py.
BTW, to any developer reading this:
A brief search through the tutorial or the FAQ included in Sage didn't
reveal anything to link to, is there a canonical point to refer to for
these questions? Where is the preparser and differences between Python
and Sage documented?
Cheers,
Burcin
sum(function for n_ in np.arange(-11,11,1))
Nevertheless, I'd be interested if there are other people out there
working with Signal Theory and stochastic signal description with sage.
I use sage since a few months in Signal Theory but even in the
notebooks, I didn't find too many examples how to solve similar problems.
Are there some sources that I didn't see yet?
Would be great to see how other sage users in electronic engineering and
research are working.
I'd like to improve my programming style and find more elegant solutions
for my problems (in some cases, I would love to find a solution at all).
Somebody out there?
Thanks,
Tobi