# 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 = X (Number of likely ie those not infected) = B - nu*X - c*lmd*X
# y = Y (Number of contagious) = c*X*lmd - Y*(v + nu)
# y = Z (Number of non-infectious HIV) = v*Y*(1 - p) - nu*Z
# y = A (Number of AIDS patients) = p*v*Y - A*(d + nu)
# y = lmd (Proportion of contagious, which made themselves pass HIV on the total population) = (Y*beta)/(X + Y + Z)

# params = nu (Natural death rate) == 0.03125 car nu + d ~= d (1 à 1.33/an)
# params = d (Death rates by disease) == 1 (1/an)
# params = B (Nombre de susceptibles immigrants) == 13333.3/an
# params = v (Number of immigrants may) == 0.2/an
# params = c (Number of sexual partners) == 48 (2 à 6/mois soit 48/an)
# params = p (Proportion of catching HIV) == 0.3 (10 à 30%)
# params = 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 - params*y - params*y*y,
params*y*y - y*(params + params),
params*y*(1-params) - params*y,
params*params*y - y*(params + params),
(y*params)/(y + y + y) ]

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,x) for x in f]
Y = [(x,x) for x in f]
Z = [(x,x) for x ...
edit retag close merge delete

1

To display blocks of code, either indent them with 4 spaces, or select the corresponding lines and click the "code" button (the icon with '101 010').

Can you edit your question to do that?

The way it is now, your code is almost illegible, since - some commented-out code is interpreted as headers, - multiplication signs are interpreted as italics markup, - only the indented parts of your code are displayed as code, - while the other parts are messed up with no line breaks.

1

If you've found one, you can enter an answer to your own question.

They also help anyone with a similar question in the future, who can find the answer there.

Having the questions nicely typeset and the answers written out is therefore useful.

Sort by » oldest newest most voted

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.

more