ogunmiloro

120 Reputation

6 Badges

6 years, 179 days

MaplePrimes Activity


These are questions asked by ogunmiloro


 

  restart:

  interface(rtablesize=10):

#
# Define gamma as local (don't like doing this!)
#
  local gamma:local pi:

#
# Replaced 'indexed' parameters with 'inert subscript'
# parameters - otherwise one gets a problem defining
# both the unindexed 'phi' and the indexed phi[c]
#

if false then
  A__h := .18: beta__1 := 0.8354e-1: psi := 0.7258e-1: mu__r := 0.51e-1: sigma := .165: alpha := .65: xi := 0.5e-1: gamma := .131: A__b := .7241: beta__o := 0.65e-1: mu__b = 0.17e-1:
end if:

#
# D() is Maple's differential operator replated D(T)
# with DD(T) in the following to avoid confusion
#
  ODE1 := diff(S(T), T) = A__h-psi*beta__1*S(T)*G(T)-mu__r*S(T):
  ODE2 := diff(G(T), T) = psi*beta__1*S(T)*G(T)-sigma*psi*beta__1*R(T)*B(T)-(alpha+xi+mu__r)*G(T):
  ODE3 := diff(A(T), T) = alpha*G(T)-(gamma+mu__r)*A(T):
  ODE4 := diff(R(T), T) = gamma*A(T)+sigma*psi*beta__1*R(T)*B(T)- mu__r*R(T):
  ODE5 := diff(C(T), T) = A__b - psi*beta__o*C(T)*I(T)- mu__b*C(T):
  ODE6 := diff(B(T), T) = psi*beta__o*C(T)*I(T)- mu__b*B(T):
 

 
if false then
  S0 := 100: G0 := 190: A0 := 45: R0 := 20: C0 := 35: B0 := 25:
end if:

# system + ic


sys := { ODE1, ODE2, ODE3, ODE4, ODE5, ODE6,
                   S(0) = S0, G(0) = G0, A(0) = A0, R(0) = R0, C(0) = C0, B(0) = B0

                 }:

params := convert(indets(sys, name) minus {T}, list);

[A0, A__b, A__h, B0, C0, G0, R0, S0, alpha, beta__1, beta__o, gamma, mu__b, mu__r, psi, sigma, xi]

(1)

#
# Solve system
#
  ans := dsolve( { ODE1, ODE2, ODE3, ODE4, ODE5, ODE6,
                   S(0) = S0, G(0) = G0, A(0) = A0, R(0) = R0, C(0) = C0, B(0) = B0
               
                 },
                 parameters = params,
                 numeric
               );

Error, (in dsolve/numeric) 'parameters' must be specified as a list of unique unassigned names

 

# define parameter values

DefaultValues := [ A__h = .18, beta__1 = 0.8354e-1, psi = 0.7258e-1, mu__r = 0.51e-1, sigma = .165, alpha = .65, xi = 0.5e-1, gamma = .131, A__b = .7241, beta__o = 0.65e-1, mu__b = 0.17e-1,
     S0 = 100, G0 = 190, A0 = 45, R0 = 20, C0 = 35, B0 = 25   
]:

# Form the list of numerical values ordered as params

ValuatedParams := subs(DefaultValues, params)
   

Warning, inserted missing semicolon at end of statement

 

[45, .7241, .18, 25, 35, 190, 20, 100, .65, 0.8354e-1, 0.65e-1, .131, 0.17e-1, 0.51e-1, 0.7258e-1, .165, 0.5e-1]

(2)

# Instanciate the solution for this set of values

ans(parameters=ValuatedParams)

Warning, inserted missing semicolon at end of statement

 

ans(parameters = [45, .7241, .18, 25, 35, 190, 20, 100, .65, 0.8354e-1, 0.65e-1, .131, 0.17e-1, 0.51e-1, 0.7258e-1, .165, 0.5e-1])

(3)

#
# Plot solutions for a few of the dependent variablss
# just to show everything is working (more-or-less!)
#

  plots:-odeplot( ans, [T, S(T)] , T=0..10);
  plots:-odeplot( ans, [T, G(T)] , T=0..10);
  plots:-odeplot( ans, [T, A(T)] , T=0..10);
   plots:-odeplot( ans, [T,R(T)] , T=0..10);
  plots:-odeplot( ans, [T, C(T)] , T=0..10);
  plots:-odeplot( ans, [T, B(T)] , T=0..10);


if false then
  plots:-odeplot( ans, [T, S(T)] , T=0..10);
  plots:-odeplot( ans, [T, G(T)] , T=0..10);
  plots:-odeplot( ans, [T, A(T)], T=0..10);
  plots:-odeplot( ans, [T, R(T)] , T=0..10);
  plots:-odeplot( ans, [T, C(T)] , T=0..10);
  plots:-odeplot( ans, [T, B(T)] , T=0..10);
 


end if:

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

# How two use the parametric solution?
#
# Here an example with only one variable parameter, but this could be generalized to many
# (the main problem is then more a problem of "readability" than a technical one).
#

f := proc(VariableName::symbol, ParamName::symbol, ParamValues::list, params, ParamDefault, sol)
  local V, k, p, MyChoice, ValuatedParams:
  V := unapply(VariableName(T), T):
  k := 0:
  for p in ParamValues do
    k := k+1:
    MyChoice       := map(u -> if lhs(u)=ParamName then lhs(u)=p else u end if, ParamDefault):
    ValuatedParams := subs(MyChoice, params):
    sol(parameters=ValuatedParams):
    plot||k := plots:-odeplot(
                               sol,
                               [T, V(T)] ,
                               T=0..5,
                               legend=p,
                               color=ColorTools:-Color([rand()/10^12, rand()/10^12, rand()/10^12])
                             );
  end do:
  plots:-display(seq(plot||k, k=1..numelems(ParamValues)));
end proc:

f(B, epsilon, [0.0001, 0.334, 5.078], params, DefaultValues, ans);

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

 

f(B, beta, [0.1, 0.28, 0.35], params, DefaultValues, ans);

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

 

f(B, alpha , [0.23,0.28, 0.32], params, DefaultValues, ans);

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

 

f(J, tau , [0.04, 0.05, 0.06], params, DefaultValues, ans);

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

f(C, theta__h , [0.6, 0.7902, 0.8], params, DefaultValues, ans);

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

``


 

Download Mapdocx.mw


 

restart; _local(gamma); _local(I); m := 3; A := 10; delta := .112; rho := .23; beta := 1.4; alpha := 2.1; gamma := 1.02; q := 2.3; b1 := 50; b2 := 10; b3 := 5; b4 := 20; S(0) := b1; B(0) := b2; V(0) := b3; R(0) := b4; mu := .13; i = 1; for k from 0 to m do S(k+1) := (A*delta*k-(rho+mu)*S(k)-beta*(sum(S(m)*B(j-m), j = 0 .. m)))/(k+1); B(k+1) := -(-(mu+alpha+gamma)*B(k)+beta*(sum(S(m)*B(j-m), j = 0 .. m)))/(k+1); V(k+1) := (rho*S(k)-(1-q)*S(k)-mu*V(k))/(k+1); R(k+1) := (gamma*B(k)-mu*R(k))/(k+1) end do; s := sum(S(kk)*t^kk, kk = 0 .. m); b := sum(B(kk)*t^kk, kk = 0 .. m); v := sum(V(kk)*t^kk, kk = 0 .. m); r := sum(R(kk)*t^kk, kk = 0 .. m); SS(0) := s; BB(0) := b; VV(0) := v; RR(0) := r; S(0) := subs(t = T(i), s); B(0) := subs(t = T(i), b); V(0) := subs(t = T(i), v); R(0) := subs(t = T(i), r)

I

 

Warning, The imaginary unit, I, has been renamed _I

 

3

 

10

 

.112

 

.23

 

1.4

 

2.1

 

1.02

 

2.3

 

50

 

10

 

5

 

20

 

50

 

10

 

5

 

20

 

.13

 

i = 1

 

-18.00-1.4*S(3)*B(-3)-1.4*S(3)*B(-2)-1.4*S(3)*B(-1)-14.0*S(3)

 

32.50-1.4*S(3)*B(-3)-1.4*S(3)*B(-2)-1.4*S(3)*B(-1)-14.0*S(3)

 

75.85

 

7.60

 

3.800000000-.4480000000*S(3)*B(-3)-.4480000000*S(3)*B(-2)-.4480000000*S(3)*B(-1)-4.480000000*S(3)

 

52.81250000-2.975000000*S(3)*B(-3)-2.975000000*S(3)*B(-2)-2.975000000*S(3)*B(-1)-29.75000000*S(3)

 

-18.70025000-1.071000000*S(3)*B(-3)-1.071000000*S(3)*B(-2)-1.071000000*S(3)*B(-1)-10.71000000*S(3)

 

16.08100000-.7140000000*S(3)*B(-3)-.7140000000*S(3)*B(-2)-.7140000000*S(3)*B(-1)-7.140000000*S(3)

 

.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3)

 

55.85709723-1.296018889*S(3)*B(-3)-1.296018889*S(3)*B(-2)-1.296018889*S(3)*B(-1)-12.96018889*S(3)-.4666666667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.4666666667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.4666666667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)

 

2.748344167-.1820700000*S(3)*B(-3)-.1820700000*S(3)*B(-2)-.1820700000*S(3)*B(-1)-1.820700000*S(3)

 

17.25940667-.9805600000*S(3)*B(-3)-.9805600000*S(3)*B(-2)-.9805600000*S(3)*B(-1)-9.805600000*S(3)

 

-.2034933335+1.482334934*S(3)*B(-3)+1.482334934*S(3)*B(-2)+1.482334934*S(3)*B(-1)+14.82334934*S(3)-.3500000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.3500000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.3500000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)

 

44.36655818+.3921579862*S(3)*B(-3)+.3921579862*S(3)*B(-2)+.3921579862*S(3)*B(-1)+3.921579862*S(3)-.7291666668*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.7291666668*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.7291666668*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)

 

0.2185881458e-1-.1520195250*S(3)*B(-3)-.1520195250*S(3)*B(-2)-.1520195250*S(3)*B(-1)-1.520195250*S(3)

 

13.68262908-.2986166168*S(3)*B(-3)-.2986166168*S(3)*B(-2)-.2986166168*S(3)*B(-1)-2.986166168*S(3)-.1190000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.1190000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.1190000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)

 

50+(-22.06933333-1.4*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-1.4*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-1.4*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+5.780693334*S(3)*B(-3)+5.780693334*S(3)*B(-2)+5.780693334*S(3)*B(-1)+57.80693334*S(3))*T(i)+(2.497813333-.4480000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.4480000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.4480000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+1.849821867*S(3)*B(-3)+1.849821867*S(3)*B(-2)+1.849821867*S(3)*B(-1)+18.49821867*S(3))*T(i)^2+(-.9095153783-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+1.704919154*S(3)*B(-3)+1.704919154*S(3)*B(-2)+1.704919154*S(3)*B(-1)+17.04919154*S(3))*T(i)^3

 

10+(28.43066667-1.4*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-1.4*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-1.4*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+5.780693334*S(3)*B(-3)+5.780693334*S(3)*B(-2)+5.780693334*S(3)*B(-1)+57.80693334*S(3))*T(i)+(44.16516667-2.975000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-2.975000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-2.975000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+12.28397333*S(3)*B(-3)+12.28397333*S(3)*B(-2)+12.28397333*S(3)*B(-1)+122.8397333*S(3))*T(i)^2+(52.09000233-1.296018889*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-1.296018889*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-1.296018889*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+5.351348394*S(3)*B(-3)+5.351348394*S(3)*B(-2)+5.351348394*S(3)*B(-1)+53.51348394*S(3)-.4666666667*(-.9095153783-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+1.704919154*S(3)*B(-3)+1.704919154*S(3)*B(-2)+1.704919154*S(3)*B(-1)+17.04919154*S(3))*B(-3)-.4666666667*(-.9095153783-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+1.704919154*S(3)*B(-3)+1.704919154*S(3)*B(-2)+1.704919154*S(3)*B(-1)+17.04919154*S(3))*B(-2)-.4666666667*(-.9095153783-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.4129066667*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+1.704919154*S(3)*B(-3)+1.704919154*S(3)*B(-2)+1.704919154*S(3)*B(-1)+17.04919154*S(3))*B(-1))*T(i)^3

 

5+75.85*T(i)+(-21.81329000-1.071000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-1.071000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-1.071000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+4.422230400*S(3)*B(-3)+4.422230400*S(3)*B(-2)+4.422230400*S(3)*B(-1)+44.22230400*S(3))*T(i)^2+(2.219127367-.1820700000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.1820700000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.1820700000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+.7517791681*S(3)*B(-3)+.7517791681*S(3)*B(-2)+.7517791681*S(3)*B(-1)+7.517791681*S(3))*T(i)^3

 

20+7.60*T(i)+(14.00564000-.7140000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.7140000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.7140000000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+2.948153600*S(3)*B(-3)+2.948153600*S(3)*B(-2)+2.948153600*S(3)*B(-1)+29.48153600*S(3))*T(i)^2+(14.40924560-.9805600000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-3)-.9805600000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-2)-.9805600000*(.2906666667-.4129066667*S(3)*B(-3)-.4129066667*S(3)*B(-2)-.4129066667*S(3)*B(-1)-4.129066667*S(3))*B(-1)+4.048797611*S(3)*B(-3)+4.048797611*S(3)*B(-2)+4.048797611*S(3)*B(-1)+40.48797611*S(3))*T(i)^3

(1)


 

Download badSums2.mw

First 6 7 8 9 10 Page 8 of 10