Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

endless loop using ode_solve

Im solving a system equation within a for loop, but it never ends But its ok to evaluate f1(n) outside the loop.... why?

def f1(ll):

def f1(ll):
    T=ode_solver()
    f = lambda t,y:[y[1],eqa.subs(l=ll,s=y[0],w=y[1],x=t)]
    T.function=f
    T.y_0=[0,1]
    T.algorithm="rk4"
    T.t_span=[0,1]
    T.h=1
    T.ode_solve(num_points=40)
    s=T.solution[-1][1][0]-1
    return s


for i in range(1) :g(i)

endless loop using ode_solve

Im solving a system equation within a for loop, but it never ends But its ok to evaluate f1(n) outside the loop.... why?

def f1(ll):

 def f1(ll):
     T=ode_solver()
     f = lambda t,y:[y[1],eqa.subs(l=ll,s=y[0],w=y[1],x=t)]
     T.function=f
     T.y_0=[0,1]
     T.algorithm="rk4"
     T.t_span=[0,1]
     T.h=1
     T.ode_solve(num_points=40)
     s=T.solution[-1][1][0]-1
     return s
 
for i in range(1) :g(i)
range(3) :f1(i)


doesn't works except when f(1) ,otherwise  the solver is unable to end

where eq is

var('l s x')
eq=((l^2 + l)*s - 2*w*x)/(x^2 - 1)

in the other hand this works

def g(ll):
    Sol=desolve_system_rk4([w,eqa(l=ll)],[s,w],ics=[0,0,1],end_points=[1.0],ivar=x,step=0.01)
    return (Sol[len(Sol)-1][1]-1)
for i in range(3) :f1(i)

so.. whats the problem with ode_solver?

endless loop using ode_solve

Im solving a system equation within a for loop, but it never ends But its ok to evaluate f1(n) outside the loop.... why?

def f1(ll):

    def f1(ll):
        T=ode_solver()
        f = lambda t,y:[y[1],eqa.subs(l=ll,s=y[0],w=y[1],x=t)]
        T.function=f
        T.y_0=[0,1]
        T.algorithm="rk4"
        T.t_span=[0,1]
        T.h=1
        T.ode_solve(num_points=40)
        s=T.solution[-1][1][0]-1
        return s

for i in range(3) :f1(i)


doesn't works except when f(1) ,otherwise  the solver is unable to end

where eq is

var('l s x')
x w')
eq=((l^2 + l)*s - 2*w*x)/(x^2 - 1)

in the other hand this works

def g(ll):
    Sol=desolve_system_rk4([w,eqa(l=ll)],[s,w],ics=[0,0,1],end_points=[1.0],ivar=x,step=0.01)
    return (Sol[len(Sol)-1][1]-1)
for i in range(3) :f1(i)

so.. whats the problem with ode_solver?

endless loop using ode_solve

Im solving a system equation within a for loop, but it never ends But its ok to evaluate f1(n) outside the loop.... why?

def f1(ll):

    def f1(ll):
        T=ode_solver()
        f = lambda t,y:[y[1],eqa.subs(l=ll,s=y[0],w=y[1],x=t)]
        T.function=f
        T.y_0=[0,1]
        T.algorithm="rk4"
        T.t_span=[0,1]
        T.h=1
        T.ode_solve(num_points=40)
        s=T.solution[-1][1][0]-1
        return s

for i in range(3) :f1(i)


doesn't works except when f(1) ,otherwise  the solver is unable to end

where eq eqa is

var('l s x w')
eq=((l^2 eqa=((l^2 + l)*s - 2*w*x)/(x^2 - 1)

in the other hand this works

def g(ll):
    Sol=desolve_system_rk4([w,eqa(l=ll)],[s,w],ics=[0,0,1],end_points=[1.0],ivar=x,step=0.01)
    return (Sol[len(Sol)-1][1]-1)
for i in range(3) :f1(i)

so.. whats the problem with ode_solver?

endless loop using ode_solve

Im solving a system equation within a for loop, but it never ends But its ok to evaluate f1(n) outside the loop.... why?

def f1(ll):

    def f1(ll):
        T=ode_solver()
        f = lambda t,y:[y[1],eqa.subs(l=ll,s=y[0],w=y[1],x=t)]
        T.function=f
        T.y_0=[0,1]
        T.algorithm="rk4"
        T.t_span=[0,1]
        T.h=1
        T.ode_solve(num_points=40)
        s=T.solution[-1][1][0]-1
        return s

for i in range(3) :f1(i)


doesn't works except when f(1) ,otherwise  the solver is unable to end
end. But f(1) or eqa(l=1) is the real solution--- :S

where eqa is

var('l s x w')
eqa=((l^2 + l)*s - 2*w*x)/(x^2 - 1)

in the other hand this works

def g(ll):
    Sol=desolve_system_rk4([w,eqa(l=ll)],[s,w],ics=[0,0,1],end_points=[1.0],ivar=x,step=0.01)
    return (Sol[len(Sol)-1][1]-1)
for i in range(3) :f1(i)

so.. whats the problem with ode_solver?