Ask Your Question

LordHorus's profile - activity

2016-11-05 07:55:46 +0200 answered a question How to resolve this problem (differential equations) ?

I found the problem, it comes from lmd (in the return of def f_1 (t,y,params)) which isn't a differential equation so I don't had to write this there but declare it alone.

2016-11-04 19:59:24 +0200 commented question How to resolve this problem (differential equations) ?

It's ok, I found the solution anyways ^^ Thanks :)

2016-11-03 16:12:15 +0200 asked a question How to resolve this problem (differential equations) ?

Hi ! I wrote a code for a project which concerns differential equations but the problem is I don't have the good curves, even if the code is right (I think). Or it's a problem of syntax but I spend a lot of time searching this, without success. I give you the code accompanied with the formulas and the exit of the code. I can't add hyperlink so I write like this or you can't understand my problem. Sorry for inconvenience !

http://image.noelshack.com/fichiers/2...

http://image.noelshack.com/fichiers/2...

http://image.noelshack.com/fichiers/2...

I'm supposed to get them curves :/ The only problem seems to be black curve (on SageMath) which is the green curve on Excel (third picture) and I don't wanted to put the black curve of Excel (so it's normal if it doesn't appear).

http://image.noelshack.com/fichiers/2...

# y[0] = X (Number of likely ie those not infected) = B - nu*X - c*lmd*X
# y[1] = Y (Number of contagious) = c*X*lmd - Y*(v + nu)
# y[2] = Z (Number of non-infectious HIV) = v*Y*(1 - p) - nu*Z
# y[3] = A (Number of AIDS patients) = p*v*Y - A*(d + nu)
# y[4] = lmd (Proportion of contagious, which made themselves pass HIV on the total population) = (Y*beta)/(X + Y + Z)

# params[0] = nu (Natural death rate) == 0.03125 car nu + d ~= d (1 à 1.33/an)
# params[1] = d (Death rates by disease) == 1 (1/an)
# params[2] = B (Nombre de susceptibles immigrants) == 13333.3/an
# params[3] = v (Number of immigrants may) == 0.2/an
# params[4] = c (Number of sexual partners) == 48 (2 à 6/mois soit 48/an)
# params[5] = p (Proportion of catching HIV) == 0.3 (10 à 30%)
# params[6] = beta (Transmission probability) == 0.0014
# t (Time)

@interact
def interactive_function ( nu = slider (0.001, 0.1, 0.005, default = 0.03125),
                           d = slider (0, 1.5, 0.05, default = 1),
                           B = slider (0, 30000, 500, default = 13333.3),
                           v = slider (0, 1, 0.05, default = 0.2),
                           c = slider (0, 365, 1, default = 48),
                           p = slider (0, 1, 0.05, default = 0.3),
                           beta = slider (0, 1, 0.02, default = 0.014) ) :

  def f_1 (t,y,params) :

    return [ params[2] - params[0]*y[0] - params[4]*y[4]*y[0],
             params[4]*y[0]*y[4] - y[1]*(params[3] + params[0]),
             params[3]*y[1]*(1-params[5]) - params[0]*y[2],
             params[5]*params[3]*y[1] - y[3]*(params[1] + params[0]),
             (y[1]*params[6])/(y[0] + y[1] + y[2]) ]


  T = ode_solver()
  T.function = f_1
  T.algorithm = "rk8pd"
  T.ode_solve (y_0 = [60000,40000,0,0,0.0056],
               t_span = [0,35],
               params = [nu,d,B,v,c,p,beta],
               num_points = 1000)

  f = T.solution
  X = [(x[0],x[1][0]) for x in f]
  Y = [(x[0],x[1][1]) for x in f]
  Z = [(x[0],x[1][2]) for x ...
(more)
2016-10-27 21:51:17 +0200 commented question I've some problems with modelization of differential equations

It's ok, paulmasson helped me on another post, thanks anyways ! :)

2016-10-27 21:50:29 +0200 commented answer How to correct them errors ?

Oh ok I'll try to understand how it works really because I've to explain this x) Thanks a lot for this savior help ! :p

2016-10-26 00:28:52 +0200 asked a question How to correct them errors ?

Hi ! I've to type a code for a math project with SageMath but I don't know really how it works because I don't learnt to use it. So I already typed this (with the help of another people) and it returns them errors :/ Sorry for the indentation but on this website it's hard to put properly the code.

Code

# y[0] = X : – B - nuX - (lmd)cX
# y[1] = Y : (lmd)cX - (v + nu)Y
# y[2] = Z : (1 - p)vY - nuZ
# y[3] = A : pvY - (d + nu)A
# y[4] = lmd : ((beta)Y / (X + Y + Z))
# params[0] = nu : natural death rate == 0.03125
# params[1] = d : AIDS death rates == 1
# params[2] = B : immigration rate people likely == 13333.3
# params[3] = v : conversion rate HIV-> AIDS == 0.2
# params[4] = c : number of sexual partners == 4
# params[5] = p : infectious HIV-positive proportion == 0.3
# params[6] = beta : transmission probability == 0.014
# t : temps
# ----------
@interact
def interactive_function(nu = slider(0.01, 0.1, 0.005, default=0.03125),
                         d = slider(0, 1, 0.05, default=1),
                         B = slider(500, 30000, 250, default=13333),
                         v = slider(0, 1, 0.05, default=0.2),
                         c = slider(0, 50, 1, default=4),
                         p = slider(0, 1, 0.05, default=0.3),
                         beta = slider(0, 1, 0.002, default=0.014),):

    def f_1(t,y,params) :
        return [ -params[2]-params[0]*y[0]-y[4]*params[4]*y[0] , y[4]*params[4]*y[0]-(params[3]+params[0])*y[1], (1-params[5])*params[3]*y[1]-params[0]*y[2], params[5]*params[3]*y[1]-(params[1]+params[0])*y[3], (params[6]*y[1])/(y[0]+y[1]+y[2]) ]

    T = ode_solver()
    T.function = f_1
    T.algorithm="rk8pd"
    T.ode_solve( y_0=[lmd,0,1-lmd,0] , t_span=[0,150] , params=[nu,d,B,v,c,p,beta] , num_points=1000)

    f = T.solution
    X = [(x[0],x[1][0]) for x in f]
    Y = [(x[0],x[1][1]) for x in f]
    Z = [(x[0],x[1][2]) for x in f]
    A = [(x[0],x[1][3]) for x in f]
    lmd = [(x[0],x[1][4]) for x in f]

    P1 = line(X, rgbcolor='green')
    P2 = line(Y, rgbcolor='pink')
    P3 = line(Z, rgbcolor='red')
    P4 = line(A, rgbcolor='brown')
    P5 = line(lmd, rgbcolor='green')
    show(P1+P2+P3+P4+P5)

Errors

Interact state: {'c': 4, 'B': 51, 'd': 20, 'p': 6, 'beta': 7, 'v': 4, 'nu': 4}
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-1-9ebe0a9051da> in <module>()
     20                          c = slider(Integer(0), Integer(50), Integer(1), default=Integer(4)),
     21                          p = slider(Integer(0), Integer(1), RealNumber('0.05'), default=RealNumber('0.3')),
---> 22                          beta = slider(Integer(0), Integer(1), RealNumber('0.002'), default=RealNumber('0.014')),):
     23 
     24     def f_1(t,y,params) :

/home/sc_serv/sagecell/misc.pyc in my_wrap(*args, **kwargs)
    153         if len(kwargs)==0 and len(args)==1 and callable(func):
    154             # call without parentheses
--> 155             return func(*args)
    156         else:
    157 ...
(more)
2016-10-25 15:04:13 +0200 commented question I've some problems with modelization of differential equations

Oh true, sorry x) But then I got them errors :/

http://www.noelshack.com/2016-43-1477344904-sans-titre.png (http://www.noelshack.com/2016-43-1477...)

2016-10-24 16:53:40 +0200 asked a question I've some problems with modelization of differential equations

Hi ! I've a project in mathematics and I'm supposed to modelize 5 functions according to various parameters that vary (hence the use of sliders). But I can't because it is highly developed functions and I had no lessons on this program. I give you the code which gives me this error:

  File "<ipython-input-1-943112df05f1>", line 30
    T.ode_solve( y_0=[lambda,Integer(0),Integer(1)-lambda,Integer(0)] , t_span=[Integer(0),Integer(150)] , params=[nu,d,B,v,c,p,beta] , num_points=Integer(1000))
                            ^
SyntaxError: invalid syntax

Code

# y[0] = X : – B - nuX - (lambda)cX
# y[1] = Y : (lambda)cX - (v + nu)Y
# y[2] = Z : (1 - p)vY - nuZ
# y[3] = A : pvY - (d + nu)A
# y[4] = lambda : ((beta)Y / (X + Y + Z))
# params[0] = nu : natural death rate == 0.03125
# params[1] = d : AIDS death rate == 1
# params[2] = B : immigration rate of people likely == 13333.3
# params[3] = v : conversion rate HIV-> AIDS == 0.2
# params[4] = c : number of sexual partners == 4
# params[5] = p : infectious HIV-positive proportion == 0.3
# params[6] = beta : probability of transmission == 0.014
# t : temps

@interact
def interactive_function(nu = slider(0.01, 0.1, 0.005, default=0.03125),
                         d = slider(0, 1, 0.05, default=1),
                         B = slider(500, 30000, 250, default=13333),
                         v = slider(0, 1, 0.05, default=0.2),
                         c = slider(0, 50, 1, default=4),
                         p = slider(0, 1, 0.05, default=0.3),
                         beta = slider(0, 1, 0.002, default=0.014),):

    def f_1(t,y,params) :
        return [ -params[2]-params[0]*y[0]-y[4]*params[4]*y[0] , y[4]*params[4]*y[0]-(params[3]+params[0])*y[1], (1-params[5])*params[3]*y[1]-params[0]*y[2], params[5]*params[3]*y[1]-(params[1]+params[0])*y[3], (params[6]*y[1])/(y[0]+y[1]+y[2]) ]

    T = ode_solver()
    T.function = f_1
    T.algorithm="rk8pd"
    T.ode_solve( y_0=[lambda,0,1-lambda,0] , t_span=[0,150] , params=[nu,d,B,v,c,p,beta] , num_points=1000 )

    f = T.solution
    X = [(x[0],x[1][0]) for x in f]
    Y = [(x[0],x[1][1]) for x in f]
    Z = [(x[0],x[1][2]) for x in f]
    A = [(x[0],x[1][3]) for x in f]
    lambda = [(x[0],x[1][4]) for x in f]

    P1 = line(X, rgbcolor='green')
    P2 = line(Y, rgbcolor='pink')
    P3 = line(Z, rgbcolor='red')
    P4 = line(A, rgbcolor='brown')
    P5 = line(lambda, rgbcolor='green')
    show(P1+P2+P3+P4+P5)

Thanks for the help you can bring to me !

Cordially, LordHorus.

PS = Sorry if my english can be wrong, I'm french :p