This works:
var('t')
h = 1/10
f = exp(t)*cos(t) - exp(t)*sin(t) #la ecuacion diferencial
def x(n):
if n == 0:
return 1 #punto conocido
else:
return (x(n-h) + h*f(n-h)) #funcion de Euler
for i in range(10):
print RR(x(i*h))
On Thu, Oct 2, 2008 at 12:35 PM, Janzo <[EMAIL PROTECTED]> wrote:
>
> Hi guys I have a problem with this recursive function, I am getting a
> infinite loop.
>
> The thing is that it is working fine for x(h), x(2*h) but not for any
> upper value.
>
> Any suggestions? Thanks a lot.
>
>
>
> var('h,t')
> h = 0.1
> f = exp(t)*cos(t) - exp(t)*sin(t) #la ecuacion diferencial
>
> def x(n):
> if n == 0:
> return 1 #punto conocido
> else:
> return (x(n-h) + h*f(n-h)) #funcion de Euler
>
> for i in range(10):
> print x(i*h)
> >
>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---