tomleslie

12175 Reputation

19 Badges

12 years, 176 days

MaplePrimes Activity


These are replies submitted by tomleslie

@Christopher2222 

Firs of all,  I agree with you that defining colors in display() rathere than in the individual plot() commands within display() results in a black/black color scheme, except for a little "splash" of red arounf the areas where the two plots "intersect". (This little "splash" of red at the intersection are does not appear on this site, but it does in the worksheet!!)

On the other hand if the color is defined within individual plot commands, then it *appears* to be obeyed. See the difference in the attached.

  with(plots):
  interface(version);

`Standard Worksheet Interface, Maple 2016.2, Windows 7, January 13 2017 Build ID 1194701`

(1)

  display
  ( tubeplot
    ( [cos(t), 0, sin(t)],
      t = -Pi .. Pi, radius = .2
    ),
    tubeplot
    ( [cos(t), sin(t), 0],
      t = -Pi .. Pi, radius = .2
    ),
    style = surface,
    color = [red, red]
  );
  display
  ( tubeplot
    ( [cos(t), 0, sin(t)],
      t = -Pi .. Pi, radius = .2,
      color = [red]
    ),
    tubeplot
    ( [cos(t), sin(t), 0],
      t = -Pi .. Pi, radius = .2,
      color = [red]
    ),
    style = surface
  );

 

 

 

 


 

Download curious.mw

because I cannot reproduce.

If you use the plottools:-getdata() command as in the attached, what colors are returned?

restart;

kernelopts(version);

`Maple 2022.1, X86 64 WINDOWS, May 26 2022, Build ID 1619613`

(1)

with(plots):

Two intersecting tori colored red and green -- works as expected:

display(
        tubeplot([cos(t), 0, sin(t)], t=-Pi..Pi, radius=0.2),
        tubeplot([cos(t), sin(t), 0], t=-Pi..Pi, radius=0.2),
style=surface, color=[red,green]);
plottools:-getdata(%, 'includecolor')[1..2,4];

 

["RGB", Vector[row](3, {(1) = 1., (2) = 0., (3) = 0.})], ["RGB", Vector[row](3, {(1) = 0., (2) = 1., (3) = 0.})]

(2)

When we set both colors to red, one of the surfaces is painted black!  Why?

Please note: This website displays the colors corectly as red and red.  But

within the worksheet the colors are read and black.

display(
        tubeplot([cos(t), 0, sin(t)], t=-Pi..Pi, radius=0.2),
        tubeplot([cos(t), sin(t), 0], t=-Pi..Pi, radius=0.2),
style=surface, color=[red,red]);
plottools:-getdata(%, 'includecolor')[1..2,4];

 

["RGB", Vector[row](3, {(1) = 1., (2) = 0., (3) = 0.})], ["RGB", Vector[row](3, {(1) = 1., (2) = 0., (3) = 0.})]

(3)

Specifying colors as red/red within the tubeplots still produces red/black!

display(
        tubeplot([cos(t), 0, sin(t)], t=-Pi..Pi, radius=0.2, color=red),
        tubeplot([cos(t), sin(t), 0], t=-Pi..Pi, radius=0.2, color=red),
style=surface);
plottools:-getdata(%, 'includecolor')[1..2,4];

 

["RGB", Vector[row](3, {(1) = 1., (2) = 0., (3) = 0.})], ["RGB", Vector[row](3, {(1) = 1., (2) = 0., (3) = 0.})]

(4)

 


 

Download badCol.mw

The code below will at least pull-up (what appears to be?) the relevant help page. At least it has a couple of examples of using the Query(algName, "Parabolic") command.

restart:
with(DifferentialGeometry):
with(LieAlgebras):
?Query[Parabolic];

Opening this help page as a worksheet (that is View->Open Page as Worksheet from the help page menu), and executing it, all the examples in this help page *appear* to work.

a couple of good "work-arounds" I would still consider this to be a "bug"

I have submitted an SCR (aka Software Change Request, aka bug report)

which you don't understand.

An SEIR model is a compartment model which is used in epidemiology - it involves four dependent variables S(t), E(t), I(t), R(t) -hence the name SEIR, where the four dependent variables represent

  1. S(t) - number of susceptiblel individuals in a population as a function of time. For a completely "new" infection, this is pretty much the whole population
  2. E(t) - number of individual in a population who have been expose to the infection, but are not yet capable of spreading the infection. Although they have been exposed, they may, or may not, become infectious, and may or may not actually become infected themselves
  3. I(t) - number of infected individuals as a function of time. Generally this is some fraction of the number of people who what been exposed.
  4. R(t) - number oif individuals for whom the infection has been "resolved" - usually taken to mean that they have either recovered or they are dead. In other case, they are generally considered to be no longer infectious, nor are they any longer capable of being infected.

an SEIR model is a set of four (first-order) differential equations which involves the above four dependent variables.

You present a system of 8 equations, which

  1. has four equations too many for an SEIR model
  2. are static - since there are no differential equations, none of the dependent variables will vary with the independent variable (ie time)
  3. thus the whole system cannot evolve with 'time' - the independent variable, and hence can never "bifurcate", because,(as presented) any solution is static - nothing varies with time

Maybe you could ask a sensible question without using words you obviously don't understand?

Digits:=16 seems to work. See attached.

Not sure why this changed between Maple 2015 and Maple 2022 though.

I'm also not sure why the curve in the first figure doesn't render on this site - it exists in the Maple worksheet - honest! It looks exactly like the original you have posted - ie OK up to about t=~140 or so, and non-existent beyond that point

  restart:
  interface(version);
  plot(140^t*exp(-140)/t!, t = 0 .. 300);
  Digits:=16:
  plot(140^t*exp(-140)/t!, t = 0 .. 300);
  Digits:=10:

`Standard Worksheet Interface, Maple 2022.1, Windows 7, May 26 2022 Build ID 1619613`

 

 

 

 

 

Download badPlot.mw

@planetmknzm 

in fact it is a long time since I have seen a worksheet with so many basi syntactical and logical errors. In fact, so many I cannot even hope to fix them

I suggest you read the comments I have added in the atttached - and fix every one of them, before doing anything else

restart:
with(plots):
with(plottools):
with(Student[LinearAlgebra]):
#infolevel[Student[LinearAlgebra]]:=1: # why does this exist? Comment out
#with(LinearAlgebra): # why does this exist? Comment out
#with(linalg,vector,matrix,crossprod,angle): # why does this exist? Comment out
pu:=Pi/180:
evalf(pu):
d:=172;t := (2 *Pi*((d - 1) / 365)):Phi:=37.52*pu;

172

 

.6548475353

(1)

d:=72: t:=(2*Pi*((d-1)/365)):
Phi:=37.52*pu:

delta:=evalf(((0.322003-22.971*cos(t)-0.357898*cos(2*t)-0.14398*cos(3*t)+3.94638*sin(t)+0.019334*sin(2*t)+0.05928*sin(3*t)))*pu);:

-0.5992618562e-1

(2)

ws:=evalf(-arccos(-tan(Phi)*tan(delta)));
# why does this next command exist? - comment out
#
# evalf(ws);

-1.524708627

(3)

alpha:=arcsin(cos(Phi)*cos(delta)*cos(omega)+sin(Phi)*sin(delta)):
#
# the following is only used as a constituent of
# the variable 'Colm' which is not used anywhere
# in this worksheet, so why does this exist?
#
# Comment it out
#
# colm1:=evalf(seq(alpha,omega=ws..0,0.01)/pu):

gama:=arccos((sin(delta)-sin(alpha)*sin(Phi))/(cos(alpha)*cos(Phi))):
#
# the following is only used as a constituent of
# the variable 'Colm' which is not used anywhere
# in this worksheet, so why does this exist?
#
# Comment it out
#
# colm2:=evalf(seq(gama,omega=ws..0,0.01)/pu):

x:=cos(alpha)*cos(gama);
#
# the following is only used as a constituent of
# the variable 'Colm' which is not used anywhere
# in this worksheet, so why does this exist?
#
# Comment it out
#
# colm3:=(seq(x,omega=ws..0,0.01)):

-0.4750145976e-1-.6079450784*cos(omega)

(4)

y:=cos(alpha)*sin(gama);
#
# the following is only used as a constituent of
# the variable 'Colm' which is not used anywhere
# in this worksheet, so why does this exist?
#
# Comment it out
#
# colm4:=(seq(y,omega=ws..0,0.01)):

(1-(.7917170774*cos(omega)-0.3647550304e-1)^2)^(1/2)*(1-1.589642350*(-0.3767534551e-1-.4821860422*cos(omega))^2/(1-(.7917170774*cos(omega)-0.3647550304e-1)^2))^(1/2)

(5)

z:=sin(alpha);
#
# the following is only used as a constituent of
# the variable 'Colm' which is not used anywhere
# in this worksheet, so why does this exist?
#
# Comment it out
#
# colm5:=(seq(z,omega=ws..0,0.01)):
#
# The variable Colm is not used anywhere in this worksheet
# so why does the following exist? Comment it out
#
# Colm:=(<colm1>,<colm2>,<colm3>,<colm4>,<colm5>):

.7917170774*cos(omega)-0.3647550304e-1

(6)

c:=sphere([0,0,0],1,color=white,transparency=0.5):             
h3:=spacecurve([-x,-y,z],omega=ws..0,color=green,thickness=5):
h4:=spacecurve([-x,y,z],omega=ws..0,color=blue,thickness=5):
blu:=op([1,1], h4):
whattype(blu);
gre:=op([1,1], h3):
whattype(gre);
#
# Observation - both 'blu' and 'gre' are Arrays whos entries
# may be accessed using square brackets - as in blu[1,1] etc
#
# Loop index for the following started from 0 when the indexing
# for blu starts from 1, so fixed this
#
# But why do you write stuff out to a file and then read the
# the same stuff back again - this is completely pointless.
#
# A total waste of time and space on your hard drive
#
for i from 1 to 200 do
     MyFile := cat(currentdir(), "/PP.txt"):
     writeto(MyFile):
#
# 'blu' is an array whise lements can be accessed using square brackets
# as in blu[1,1]. As used below with round brackets  'blu' is a function/
# procedure with supplied arguments - no relation to the Array previously
# defined - so I have no idea what the rest of this loop is attempting to
# achieve. I can pretty much guarantee that whatever the OP wnats, this isn't
# going to do it
#
#
     PlanePlot(blu(i,1)*xx+blu(i,2)*yy+blu(i,3)*zz=0,[xx,yy,zz], showbasis ):
     close(MyFile):


     writeto(terminal):
     with(StringTools):

     fine:= readline(MyFile):
     while fine <> 0 do
           last := fine:
           fine := readline(MyFile):
           if   fine <> 0 and Search("basis vectors:", fine) =1
           then bv := StringSplit(fine, "basis vectors:")[2]:
                bv1||i, bv2||i := parse(%):
           end if:
     end do:
od:
##`basis vector 1` = bv1;
##`basis vector 2` = bv2;# benim işime yarayan vektör

Array

 

Array

(7)

#
# Following commmand will 'Error' because 'h5' is
# not defined anywhere - exactly how do you think
# you can plot something whihc is undefined????
#
# Comment it out
#
#  display(c,h4,h3,h5);
#
# 'c' 'h3' and 'h4' have been defined so can be
# displayed
#
  display(c,h4,h3);

 

#
# Hmmmmmm we seem to be repeating ourselves. Writing stuuf out to a
# hard drive, then reading the same stuff back in again.
#
# why? WHY? WHY?
#
#
MyFile := cat(currentdir(), "/PP.txt"):
writeto(MyFile):
#
# Well this won't work because it requires 'blu' to be a function/
# procedure which accepts two arguments. OP probably wants entries
# of the Array 'blu' whihc would require square brackets - as in
# blu[1,1].
#
# But we still won't get anywhere because the name 'as' is not
# defined anywhere in this worksheet
#
PlanePlot(blu(as,1)*xx+blu(as,2)*yy+blu(as,3)*zz=0,[xx,yy,zz], showbasis ):
close(MyFile):


writeto(terminal):
with(StringTools):

fine:= readline(MyFile):
while fine <> 0 do
   last := fine:
   fine := readline(MyFile):
   if   fine <> 0 and Search("basis vectors:", fine) =1
   then bv := StringSplit(fine, "basis vectors:")[2]:
        bv1, bv2 := parse(%):
   end if:
end do:

#`basis vector 1` = bv1;
#`basis vector 2` = bv2;# benim işime yarayan vektör

Error, unsupported type of index, as

 

NULL


 

Download pileOfCrap.mw

@planetmknzm 

rather than some "excerpt" which you *think* is appropriate. You can upload a worksheet using the big green up-arrow in the Mapleprimes toolbar. That way everybody here gets to see exactly what you are doing, rather than random rather meaningless code

For illustration of the problem whihc you are making impossible to diagnose, consider the first two lines of the "code" which you post, that is

c:=sphere([0,0,0],1,color=white,transparency=0.5):             
h3:=spacecurve([-x,-y,z],omega=ws..0,color=green,thickness=5):

Now let us consider the problems in these two line alone

  1. The sphere() command can only be executed after a with(plottools) command, so this command in your supplied command will never execute, it will just return as output sphere([0,0,0],1,color=white,transparency=0.5)
  2. The spacecurve() command can only be executed after a with(plots) command, so this command in your supplied command will never execute it will just return as output spacecurve([-x,-y,z],omega=ws..0,color=green,thickness=5):
  3. Even after loading the 'plots' package, the above spacecurve command will not execute because
    1. The value of 'ws' is undefined - it needs to evaluate to a numeric quantity which you do not supply
    2. The spacecurve parameter 'omega' is not used in the calculation of the spacecurve coordinates - unless you have a definition of the expressions 'x', 'y', 'z' in terms of omega - which you do not supply
  4. After two lines of so-called code, your worksheet is useless - I haven't even bthered to look at the rest of it
  5. Upload the code you are actually running

 

@Saha 

which is posted again here for your convenience. The only difference between the attached and my original is that I have included the command interface(version) immediately after the restart, just to demonstrate that this executes correctly in your version of Maple.

I fixed all your problems once. I can't think of any reason why I should do the same again

  restart;
  interface(version);
  with(plots):

`Standard Worksheet Interface, Maple 18.02, Windows 7, October 20 2014 Build ID 991181`

(1)

  eq1:= diff(f(x), x$3)
        +
        1/2*(1-phi)^2.5*(1-phi+phi*rho__s/rho__f1)*(eta*cos__omega + f(x)*sin__omega)*diff(f(x), x$2)
        +
        (1-phi)^2.5*M*sin(alpha)^2*(1-diff(f(x),x))
        +
        (1-phi)^2.5*(1-phi+phi*rho__beta__s/rho__beta__f1)*lambda__T*theta(x);

  eq2:= K__nf/K__f*diff(theta(x),x$2)
        +
        Pr/2*(eta*cos__omega + f(x)*sin__omega)*diff(theta(x),x);
#
# The OP's original list of boundary conditions contained f(1)=0.
# In a 1-dimensional BVP only two boundaries are allowed, so the
# condition f(1)=0 has been "replaced" by the condition
#
#    D(f)(0) = val
#
# A "shooting" method will be used later to determine a value for
# "val", whihc ensures that the original BC ( ie f(1)=0 ) is
# satisfied
#
  bcs := f(0) = 0, D(f)(0) = val, f(10) = 1, theta(0) = 1, theta(10) = 0;

  params:= [ K__f=0.613, K__nf=0.6842, M=1, Pr=6.2,
             alpha=0, eta=0, phi=0.05, rho__f1=997.1,
             rho__s=5200, cos__omega=1, lambda__T=0,
             rho__beta__f1=20939.1, rho__beta__s=997.1,
             sin__omega=1
           ];
#
# So the ODE system with all parameter values inserted is
#
  odesys:=eval([eq1, eq2], params);

diff(diff(diff(f(x), x), x), x)+(1/2)*(1-phi)^2.5*(1-phi+phi*rho__s/rho__f1)*(eta*cos__omega+f(x)*sin__omega)*(diff(diff(f(x), x), x))+(1-phi)^2.5*M*sin(alpha)^2*(1-(diff(f(x), x)))+(1-phi)^2.5*(1-phi+phi*rho__beta__s/rho__beta__f1)*lambda__T*theta(x)

 

K__nf*(diff(diff(theta(x), x), x))/K__f+(1/2)*Pr*(eta*cos__omega+f(x)*sin__omega)*(diff(theta(x), x))

 

f(0) = 0, (D(f))(0) = val, f(10) = 1, theta(0) = 1, theta(10) = 0

 

[K__f = .613, K__nf = .6842, M = 1, Pr = 6.2, alpha = 0, eta = 0, phi = 0.5e-1, rho__f1 = 997.1, rho__s = 5200, cos__omega = 1, lambda__T = 0, rho__beta__f1 = 20939.1, rho__beta__s = 997.1, sin__omega = 1]

 

[diff(diff(diff(f(x), x), x), x)+.5325197465*f(x)*(diff(diff(f(x), x), x)), 1.116150082*(diff(diff(theta(x), x), x))+3.100000000*f(x)*(diff(theta(x), x))]

(2)

#
# The shooting method
#
# This determines a value for D(f)(0) such that the
# OP's original desired condition f(1)=0 is satisfied
#
  SM:= proc( shoot )
             local ans:
             if type( shoot, numeric)
             then ans:= dsolve
                        ( eval
                          ( [odesys[], bcs],
                            val=shoot
                          ),
                          numeric
                        ):
                  return rhs(ans(1)[2]);
             else return 'procname(_passed)'
             fi;
       end proc:
  sv:= fsolve( SM );

-0.1290531852e-1

(3)

#
# Solve the system
#
  sol:= dsolve
        (  eval
           ( [odesys[], bcs],
             val=sv
           ),
          numeric
        ):
#
# Check that when x=1, f(x)=0, which was OP's desired condition
#
  sol(1)[1..2];
#
# Plot the results
#
  odeplot
  ( sol,
    [ [x, f(x)],
      [x, theta(x)]
    ],
    x = 0 .. 10,
    color=[red, blue],
    legend=[typeset(f(x)), typeset(theta(x))]
  );
  

[x = 1., f(x) = HFloat(1.9274077505456594e-12)]

 

 

 


 

Download odeProb.mw

 

@Tamour_Zubair

With N=5 and t=0..3, your dependent varaibles have numerical values in the range +/-10^27.

With N=6 and t=0..3, your dependent varaibles have numerical values in the range +/-10^45

With N=7 and t=0..3, you dependent varaibles have numerical values in the range +/-10^63

So every time you increase the number of equations in your system, the numerical range of the dependend variables increases by about 10^18. Based on the above, with N=8, one might expect the dependent variables to have numerical values in the range +/-10^81, which is about the same as the number of atoms in the known universe

I always get worried when I see numbers like this. Ask yourself some serious questions.

  1. If you are modelling some "real-world" phenomenon, what range of values would you expect for the dependent variables? You ought to be able to make a rough guess!
  2. Do you really believe that your system can produce values greater than the number of atoms in the universe? If so, how?, why?, what are you modelling?

@Tamour_Zubair 

You state

Thanks a lot for this. I cannot use builton command beacuse system of ODE's increase as i will increase the value of "N".

For a start, there is no 'N' in your worksheet, so what is increasing? The number of ODEs? the complexity of the ODEs?

Why do you think that you can produce some "magic code" which will work better than Maple's built-in ODE solvers?

Maybe if I understood the real problem you are trying to solve, I could make sensible suggestions

@planetmknzm 

using the big green up-arrow in the Mapleprimes toolbar to upload worksheets which are causing you a problem?

That way, responders here can execute your worksheet, figure out  possible improvements, and do all kinds of useful stuff.

On the other hand you can upload a video which doesn't show (most of) your code, so cannot be read , cannot be executed, cannot be analysed, and hence is unlikely to be "improved"

  1. Rule 1 - upload an executable worksheet
  2. Rule 2 - if you think there is a "better" approach, stop thinking and apply Rule 1

@Kitonum 

You could set the animation speed using the FPS box in Maple's animation toolbar

you still don't need the InertForm() package, entering data as strings, then parsing strings etc etc - Sure it will work, but that is the conplicated way to do something simple. See the attached for a "simple" variation on my original answer, based on the following observations

  1. entering data as strings - cumbersome and unnecessary
  2. "parsing" such entries - cumbersome and unnecessary
  3. of course the above approaches will "work", but why bother? Isn't the attached just - well, simpler?

#
# One possible variant of OP's desired expression
#
  Set:= `%+`(  1/3%*<3^(1/2), -3^(1/2), 3^(1/2), 0>,
              -1/3%*<3^(1/2),  3^(1/2), 3^(1/2), 0>
              +3*<2,1,1,0>
            );
#
# Quick check on export+import to/from MathML
#
  a:= MathML:-Export(Set):
  MathML:-Import(a);

`%+`(`%*`(1/3, Vector(4, {(1) = sqrt(3), (2) = -sqrt(3), (3) = sqrt(3), (4) = 0})), -`%*`(1/3, Vector(4, {(1) = sqrt(3), (2) = sqrt(3), (3) = sqrt(3), (4) = 0}))+(Vector(4, {(1) = 6, (2) = 3, (3) = 3, (4) = 0})))

 

`%+`(`%*`(1/3, Vector[column](%id = 36893488148080653604)), -`%*`(1/3, Vector[column](%id = 36893488148080653724))+Vector[column](%id = 36893488148080653844))

(1)

#
# Another possible variant of OP's desired expression
#
  Set:= `%+`(  1/3%*<3^(1/2), -3^(1/2), 3^(1/2), 0>,
              -1/3%*<3^(1/2),  3^(1/2), 3^(1/2), 0>,
               <2,1,1,0>
            );
#
# Quick check on  export+import to/from MathML
#
  a:= MathML:-Export(Set):
  MathML:-Import(a);

`%+`(`%*`(1/3, Vector(4, {(1) = sqrt(3), (2) = -sqrt(3), (3) = sqrt(3), (4) = 0})), -`%*`(1/3, Vector(4, {(1) = sqrt(3), (2) = sqrt(3), (3) = sqrt(3), (4) = 0})), Vector(4, {(1) = 2, (2) = 1, (3) = 1, (4) = 0}))

 

`%+`(`%*`(1/3, Vector[column](%id = 36893488148080646372)), -`%*`(1/3, Vector[column](%id = 36893488148080646492)), Vector[column](%id = 36893488148080646612))

(2)

 

Download inert3.mw

 

whether you use "worksheet mode", "Document mode", "1-D Input", "2D-input" what. You can save the worksheet on your local machine as a file with extension ".mw". Upload this file to this site using the big green up-arrow in the Mapleprimes toolbar

1 2 3 4 5 6 7 Last Page 1 of 192