Hi, 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 On 06/26/2010 02:36 PM, Tobias Katz wrote: > Hi, > > 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 > -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org