On Friday, December 14, 2012 12:41:57 PM UTC-8, Keshav Kini wrote:
>
> Santanu Sarkar <sarkar.sa...@gmail.com <javascript:>> writes: 
>
> > No, as s will be a function of a,m,t, 
>
> You can't have imperative code in a symbolic function, if that's what 
> you're asking. You can of course use an imperative (Python) function to 
> do what you want:: 
>
>     def s(m, a, t): 
>         result = 0 
>         for i in srange(1,m+1): 
>             if i > a + t: 
>                 s += 2*i 
>             else: 
>                 s += t 
>         return result 
>

Ah, so perhaps you want something along the lines of:

sage: var('i')
sage: s(m,a,t)=sum(2*i*heaviside(i-a*t)+t*heaviside(a*t-i),i,1,m)

I'm not sure whether sage can do anything useful with it. Also, the 
heaviside step function in sage is undefined at the value where it steps. 
Substitute with a cunning combination of max, min, floor, ceil, etc. to 
create the step you want if you care for values where a*t is an integer.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to