acer

32333 Reputation

29 Badges

19 years, 325 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

It's not helpful or polite to only supply an image of the equations. And so I may have mistyped something.

Also, I notice that you changed your system since you first posted the Question.

What did you obtain from calling solve?

restart;

interface(imaginaryunit=IM):

local gamma:

eqs := [lambda__H-beta__1*S__H*I__R/(S__R+I__R)-beta__2*S__H*I__H/(S__H+E__H+I__H+R__H)-mu*S__H=0,
        beta__1*S__H*I__R/(S__R+I__R)+beta__2*S__H*I__H/(S__H+E__H+I__H+R__H)-gamma*E__H-mu*E__H=0,
        gamma*E__H-kappa*I__H-alpha*I__H-mu*I__H=0,
        alpha*I__H-mu*R__H=0,
        lambda__R-tau*S__R*I__R/(S__R+I__R)-phi*S__R-delta*S__R=0,
        tau*S__R*I__R/(S__R+I__R)-phi*I__R-delta*I__R=0
       ]:

map(print, eqs):

lambda__H-beta__1*S__H*I__R/(S__R+I__R)-beta__2*S__H*I__H/(S__H+E__H+I__H+R__H)-mu*S__H = 0

beta__1*S__H*I__R/(S__R+I__R)+beta__2*S__H*I__H/(S__H+E__H+I__H+R__H)-gamma*E__H-mu*E__H = 0

E__H*gamma-I__H*alpha-I__H*kappa-I__H*mu = 0

I__H*alpha-R__H*mu = 0

lambda__R-tau*S__R*I__R/(S__R+I__R)-phi*S__R-delta*S__R = 0

tau*S__R*I__R/(S__R+I__R)-phi*I__R-delta*I__R = 0

sols := simplify(solve(eqs, [I__R,S__R,S__H,E__H,I__H,R__H], explicit)):

length(sols);

12299

nops(sols);

4

new:=map(uuuu->map(uuu->lhs(uuu)=subsindets(collect(numer(rhs(uuu)), [beta__1,beta__2], u->simplify(u,size)),`^`,uu->`^`(collect(op(1,uu), [beta__1,beta__2], u->simplify(u,size)),op(2,uu)))/simplify(denom(rhs(uuu)),size),uuuu),sols):

length(new);

8990

simplify(sols-new);

[[0, 0, 0, 0, 0, 0], [0, 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0], [0, 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0], [0, 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0]]

new[1];

[I__R = 0, S__R = lambda__R/(delta+phi), S__H = lambda__H/mu, E__H = 0, I__H = 0, R__H = 0]

new[2];

[I__R = 0, S__R = lambda__R/(delta+phi), S__H = lambda__H*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)/(mu*gamma*(beta__2-kappa)), E__H = (gamma*lambda__H*beta__2-(gamma+mu)*(alpha+kappa+mu)*lambda__H)/(gamma*(beta__2-kappa)*(gamma+mu)), I__H = (gamma*lambda__H*beta__2-(gamma+mu)*(alpha+kappa+mu)*lambda__H)/((beta__2-kappa)*(gamma+mu)*(alpha+kappa+mu)), R__H = (alpha*gamma*lambda__H*beta__2-alpha*(gamma+mu)*(alpha+kappa+mu)*lambda__H)/((beta__2-kappa)*(gamma+mu)*(alpha+kappa+mu)*mu)]

new[3];

[I__R = -lambda__R*(delta+phi-tau)/(tau*(delta+phi)), S__R = lambda__R/tau, S__H = -(1/2)*(-(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*lambda__H*beta__1+gamma*mu*tau*lambda__H*beta__2+(((mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)^2*(delta+phi-tau)^2*beta__1^2+(-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*mu*gamma*tau*beta__2-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*(gamma+mu)*(alpha+kappa+mu)*mu*tau)*beta__1+beta__2^2*gamma^2*mu^2*tau^2-2*mu^2*gamma*(gamma+mu)*(alpha+kappa+mu)*tau^2*beta__2+mu^2*(gamma+mu)^2*(alpha+kappa+mu)^2*tau^2)^(1/2)+mu*(mu^2+(alpha+gamma+kappa)*mu+gamma*(alpha-kappa))*tau)*lambda__H)/(gamma*(((-phi+tau-delta)*beta__1+mu*tau)*kappa-beta__2*mu*tau)*mu), E__H = -(1/2)*((delta+phi-tau)*(mu^2+(alpha+gamma+kappa)*mu+gamma*(alpha+2*kappa))*lambda__H*beta__1+gamma*mu*tau*lambda__H*beta__2-(((mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)^2*(delta+phi-tau)^2*beta__1^2+(-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*mu*gamma*tau*beta__2-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*(gamma+mu)*(alpha+kappa+mu)*mu*tau)*beta__1+beta__2^2*gamma^2*mu^2*tau^2-2*mu^2*gamma*(gamma+mu)*(alpha+kappa+mu)*tau^2*beta__2+mu^2*(gamma+mu)^2*(alpha+kappa+mu)^2*tau^2)^(1/2)+mu*tau*(gamma+mu)*(alpha+kappa+mu))*lambda__H)/(gamma*(((-phi+tau-delta)*beta__1+mu*tau)*kappa-beta__2*mu*tau)*(gamma+mu)), I__H = -(1/2)*((delta+phi-tau)*(mu^2+(alpha+gamma+kappa)*mu+gamma*(alpha+2*kappa))*lambda__H*beta__1+gamma*mu*tau*lambda__H*beta__2-(((mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)^2*(delta+phi-tau)^2*beta__1^2+(-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*mu*gamma*tau*beta__2-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*(gamma+mu)*(alpha+kappa+mu)*mu*tau)*beta__1+beta__2^2*gamma^2*mu^2*tau^2-2*mu^2*gamma*(gamma+mu)*(alpha+kappa+mu)*tau^2*beta__2+mu^2*(gamma+mu)^2*(alpha+kappa+mu)^2*tau^2)^(1/2)+mu*tau*(gamma+mu)*(alpha+kappa+mu))*lambda__H)/((gamma+mu)*(alpha+kappa+mu)*((mu*tau-(delta+phi-tau)*beta__1)*kappa-beta__2*mu*tau)), R__H = -(1/2)*((delta+phi-tau)*alpha*(mu^2+(alpha+gamma+kappa)*mu+gamma*(alpha+2*kappa))*lambda__H*beta__1+alpha*gamma*mu*tau*lambda__H*beta__2-(((mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)^2*(delta+phi-tau)^2*beta__1^2+(-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*mu*gamma*tau*beta__2-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*(gamma+mu)*(alpha+kappa+mu)*mu*tau)*beta__1+beta__2^2*gamma^2*mu^2*tau^2-2*mu^2*gamma*(gamma+mu)*(alpha+kappa+mu)*tau^2*beta__2+mu^2*(gamma+mu)^2*(alpha+kappa+mu)^2*tau^2)^(1/2)+mu*tau*(gamma+mu)*(alpha+kappa+mu))*alpha*lambda__H)/((gamma+mu)*(alpha+kappa+mu)*mu*((mu*tau-(delta+phi-tau)*beta__1)*kappa-beta__2*mu*tau))]

new[4];

[I__R = -lambda__R*(delta+phi-tau)/(tau*(delta+phi)), S__R = lambda__R/tau, S__H = -(1/2)*(-(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*lambda__H*beta__1+gamma*mu*tau*lambda__H*beta__2+(-((mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)^2*(delta+phi-tau)^2*beta__1^2+(-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*mu*gamma*tau*beta__2-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*(gamma+mu)*(alpha+kappa+mu)*mu*tau)*beta__1+beta__2^2*gamma^2*mu^2*tau^2-2*mu^2*gamma*(gamma+mu)*(alpha+kappa+mu)*tau^2*beta__2+mu^2*(gamma+mu)^2*(alpha+kappa+mu)^2*tau^2)^(1/2)+mu*(mu^2+(alpha+gamma+kappa)*mu+gamma*(alpha-kappa))*tau)*lambda__H)/(gamma*(((-phi+tau-delta)*beta__1+mu*tau)*kappa-beta__2*mu*tau)*mu), E__H = -(1/2)*((delta+phi-tau)*(mu^2+(alpha+gamma+kappa)*mu+gamma*(alpha+2*kappa))*lambda__H*beta__1+gamma*mu*tau*lambda__H*beta__2-(-((mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)^2*(delta+phi-tau)^2*beta__1^2+(-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*mu*gamma*tau*beta__2-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*(gamma+mu)*(alpha+kappa+mu)*mu*tau)*beta__1+beta__2^2*gamma^2*mu^2*tau^2-2*mu^2*gamma*(gamma+mu)*(alpha+kappa+mu)*tau^2*beta__2+mu^2*(gamma+mu)^2*(alpha+kappa+mu)^2*tau^2)^(1/2)+mu*tau*(gamma+mu)*(alpha+kappa+mu))*lambda__H)/(gamma*(((-phi+tau-delta)*beta__1+mu*tau)*kappa-beta__2*mu*tau)*(gamma+mu)), I__H = -(1/2)*((delta+phi-tau)*(mu^2+(alpha+gamma+kappa)*mu+gamma*(alpha+2*kappa))*lambda__H*beta__1+gamma*mu*tau*lambda__H*beta__2-(-((mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)^2*(delta+phi-tau)^2*beta__1^2+(-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*mu*gamma*tau*beta__2-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*(gamma+mu)*(alpha+kappa+mu)*mu*tau)*beta__1+beta__2^2*gamma^2*mu^2*tau^2-2*mu^2*gamma*(gamma+mu)*(alpha+kappa+mu)*tau^2*beta__2+mu^2*(gamma+mu)^2*(alpha+kappa+mu)^2*tau^2)^(1/2)+mu*tau*(gamma+mu)*(alpha+kappa+mu))*lambda__H)/((gamma+mu)*(alpha+kappa+mu)*((mu*tau-(delta+phi-tau)*beta__1)*kappa-beta__2*mu*tau)), R__H = -(1/2)*((delta+phi-tau)*alpha*(mu^2+(alpha+gamma+kappa)*mu+gamma*(alpha+2*kappa))*lambda__H*beta__1+alpha*gamma*mu*tau*lambda__H*beta__2-alpha*(-((mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)^2*(delta+phi-tau)^2*beta__1^2+(-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*mu*gamma*tau*beta__2-2*(mu^2+(alpha+gamma+kappa)*mu+alpha*gamma)*(delta+phi-tau)*(gamma+mu)*(alpha+kappa+mu)*mu*tau)*beta__1+beta__2^2*gamma^2*mu^2*tau^2-2*mu^2*gamma*(gamma+mu)*(alpha+kappa+mu)*tau^2*beta__2+mu^2*(gamma+mu)^2*(alpha+kappa+mu)^2*tau^2)^(1/2)+mu*tau*(gamma+mu)*(alpha+kappa+mu))*lambda__H)/((gamma+mu)*(alpha+kappa+mu)*mu*((mu*tau-(delta+phi-tau)*beta__1)*kappa-beta__2*mu*tau))]

map( u->print(simplify(eval(eqs, u))), new ):

[0 = 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0]

[0 = 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0]

[0 = 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0]

[0 = 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0, 0 = 0]

 

Download solve_sys.mw

You may notice that the regions overlap since they are both filled between their curves and y=0.

And so for your example (done successfully with plot and filled) the region of overlap thus gets rendered with an effect with both specified colors. Both filled regions are constructed by the plot command with a transparency. This produces a darker, purple visual appearance for the lower region (which is all overlap).

And if you added more curves then regions with more overlap would be appear darker still.

If you wish to specify colors for shading the regions between curves separately (without overlap) then you can use the plots:-shadebetween command. This allows you to force the shading to be precisely the colors you specifiy.

For example,

restart;
with(plots):

animate(display,
        ['shadebetween'(sqrt(x), sqrt(x)-1, x=0..t, color="Red"),
         'shadebetween'(sqrt(x)-1, 0, x=0..t, color="Blue"),
        view=[0..20,0..5]], t=0..20);

Here are some things you can try out:

restart;

eq := (1 + a * cos(theta1*x)) * cos(theta2*x) = b:

this := eval(eq, [a=0.25,b=0.1,theta1=2,theta2=24.5]):

this;

       (1 + 0.25 cos(2 x)) cos(24.5 x) = 0.1

#plot( (rhs-lhs)(this), x=0..1 );

fsolve( this, x=0..1 );

                   0.06084048514

fsolve( this, x=0..1, maxsols=10 );

      0.06084048514, 0.1956614960, 0.3171692501, 0.4523388447,
      0.5733212716, 0.7091939827, 0.8293033344, 0.9661987166

You can reduce the size of your expression.

for_transfer_to_word_ac.mw

If that's still too big then you could try splitting it into a sum of terms.

You don't need to construct procedures to do this.

You may find that additional plotting command options can make the results nicer.

u := 1-(8*(10.3968*t^2-5.8368*t*f-.229376*f^2-5.1984))/(4.56*t^2-2.56*t*f+.8192*f^2+2.28)^2:
x := f+t-(8*(-2.28*t+.64*f))/(2.28+2*(-t+.64*f)^2+2.56*t^2):

plot([eval(x,t=0), eval(u,t=0),f=-5..5]);

plot3d([x,t,u], f=-5..5, t=-5..5);
plot3d([x,t,u], f=-5..5, t=-5..5, grid=[251,251]);
plot3d([x,t,u], f=-5..5, t=-5..5, grid=[251,251], style=surface);
plot3d([x,t,u], f=-5..5, t=-5e-1..5e-1, grid=[101,101]);

You should be using left-ticks (single left quotes, a.k.a. name quotes) instead of right-ticks (single right quotes, a.k.a. unevaluation quotes).

Eg,  `-+++` instead of  '-+++'

It appears that (in three places) you wrote else if where you intended what elif would provide instead.

So, as it is, you have too few terminators (and too many stray else instances). Have a look at this recent comment if you don't understand the difference.

I don't understand what assignments you're trying to accomplish. It seems suspicious to me that you are trying to assign to the subscripted h__k in a loop with k as the loop-index. Do you understand the difference between h[k] and h__k (both of which may appear as subscripted in 2D Math)?

I don't see what's wrong with your original suggestion. Eg,

restart;

L := proc(t::realcons, A::list, B::list)
   plots:-display(plottools:-line(A, t*B-(t-1)*A));
end proc:

P, Q := [2,3], [5,-2];
N := 100;

plots:-animate(L, [t, P, Q], t=0..1, paraminfo=false, frames=N);

S := [seq(L(t,P,Q), t=0..1, 1/(N-1))]:
nops(S);

plots:-display(S, insequence);

I may be misunderstanding your request, which is not worded very clearly.

As I read your question, the only points mentioned are the end-points. But you haven't actually stated that you want the animation to consist of plotting points. So above I've connected the two end-points with a (growing, animated) line segment. Please clarify your intention.

In Maple square brackets denote lists, and they do not group terms, ie. they do not indicate mathematical grouping of subexpressions.

So your expectation is invalid, given the role of square brackets in Maple. It works if you remove them.

expr := A*sin(x)^2+A*cos(x)^2;

                        2           2
        expr := A sin(x)  + A cos(x)

simplify(A);

                     A

You can use parentheses (round brackets) to group terms in Maple. None are needed for your example, however. For example the following produces the same expression as above,

A*(sin(x)^2)+A*(cos(x)^2);

                    2           2
            A sin(x)  + A cos(x)

That may be really old Maple, in which a literal dot (ie, . ) was used to denote concatenation.

I haven't modified the whole thing to use the modern LinearAlgebra package instead of the now deprecated linalg package, but here it is using the cat commant instead of that dot.

If you can check whether this is the expected result then we could also revise it to use LinearAlgebra.

restart

N := 2; A := -N; B := N

q := .3; p := .5; sa := .9; sb := .1; r := 1-p-q

with(linalg)

dimP := 2*N+1

P := matrix(dimP, dimP, [`$`(0, dimP*dimP)])

P[1, 1] := sa; P[1, 2] := 1-sa; P[dimP, dimP] := sb; P[dimP, dimP-1] := 1-sb

for i from 2 to dimP-1 do P[i, i-1] := q; P[i, i] := r; P[i, i+1] := p end do

P0 := P

"for n from 1 to 10 do   cat(P,n):=evalm(cat(P,(n-1)) &* P0):  end do:"

print(P10)

P10

NULL

Download TransitionMatix_ac.mw

Make sure that you are using indexed names for the subscripting and not literal subscripts.

By that I mean enter them as theta[i] and theta[3] etc. Or use Ctrl-Shift-underscore in 2D Input mode. Don't use the double-underscore theta__i and theta__3, etc or anything from the Layout pallete.

The values of zero that you obtatined make me suspect this might be one of your issues.

 

You named your procedure RandWalk, so you won't get a plot by calling it wrongly with the name RandomWalk.

Try changing those else if instances into elif .

randomWalk_ac.mw

Your original c and p procedures both return lists, not scalar values. And so your plotting attempt does not match any of the valid calling sequences for the plot command.

If you get rid of the square brackets then they both return scalar values and then plotting is straightforward. Your original call  plot(c(f), f = 50 .. 100)  would also then work.

restart;

with(Statistics):

X := RandomVariable(Normal(0, 1)):
K := 150: r := 0.25e-1: s := .75: t := .5:
d1 := f-> (log(f/K)+.5*s^2*t)/(s*sqrt(t)):

d2 := f-> d1(f)-s*sqrt(t):

c := f-> exp(-r*t)*(f*(CDF)(X, d1(f))-K*(CDF)(X, d2(f))):

p := f->exp(-r*t)*(K*(CDF)(X, -d2(f))-f*(CDF)(X, -d1(f))):

evalf(c(100)), evalf(p(100));

8.038514278, 57.41740429

plot([c,p], 50 .. 200, size=[400,200]);

 

Download scalar_fcn.mw

restart;
eqs := [a+b+c=10, a/b=b/c, a*b=6]:

Ssol:=[solve(eqs, explicit, allsolutions)]:

remove(has,evalf(Ssol),I);

   [{a = 1.935562295, b = 3.099874421, c = 4.964563284},

    {a = 9.311003375, b = 0.644398865, c = 0.04459776043}]

fsolve(eqs);

     {a = 1.935562277, b = 3.099874424, c = 4.964563299}

fsolve(eqs, {a,b,c}, avoid={fsolve(eqs)});

     {a = 9.311003376, b = 0.6443988642, c = 0.04459776025}

RootFinding:-Isolate(map(rhs-lhs,eqs),[a,b,c]);

  [[a = 9.311003376, b = 0.6443988642, c = 0.04459776025],

   [a = 1.935562277, b = 3.099874424, c = 4.964563299]]

map(u->andmap(is,map(rhs,[simplify(u)[]]),real),Ssol);

               [true, true, false, false]

#select(u->andmap(is,map(rhs,[simplify(u)[]]),real),Ssol);
First 151 152 153 154 155 156 157 Last Page 153 of 336