acer

32333 Reputation

29 Badges

19 years, 321 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

With luck I entered it all correctly.

restart:

dsys:=diff(x(t),t)=0.2*x(t)*(1-0.5*x(t))-(1.5*x(t)*y(t))/(1+0.116*x(t)),
      diff(y(t),t)=(1.3*x(t)*y(t))/(1+0.1*x(t))-0.8*y(t):
ics:=x(0)=1,y(0)=2:

P1:=DEtools[DEplot]({dsys},[x(t),y(t)],t=0..50,x=-1..3,y=-1..3,
                    [[ics]],linecolor=green,maxfun=10^5,arrows=small):

F:=proc(par)
  DEtools[DEplot]({dsys},[x(t),y(t)],t=0..50,x=-1..3,y=-1..3,
                  [[ics]],linecolor=blue,maxfun=10^5,arrows=small,
                  method=classical[foreuler],stepsize=par);
end proc:

plots:-display(P1,F(0.005));

Explore(plots:-display(P1,F(stepsize)),
        parameters=[stepsize=0.005..1.0]);

acer

Click the "New" tab beside "Popular". Then click on the rightmost of the 5 buttons at the bottom, the one which looks like a blue circle with a white downward pointing triangle in it. Pressing that will scroll down the full list by a "page" (10 items, say).

acer

One sensible appraoch, as Carl has shown, is to generate a sequence of `plot` calls, where each one sets its own color. And then `plots:-display` can handle the title. This could serve you well, if you also wanted to have differing linestyles, etc.

Another approach, which I believe works for providing multiple curve colors for the given problem, is to make just a single call to `plot` command using its own specification for handling multiple curves. This provides the immediate support of the palette functionality of plots:-setcolors to get differing colors for multiple curves using either system color palettes or user-defined lists as palette.

The final line in the procedure could be, (pasted here in plaintext 1D Maple notation)

  plot([seq]([seq]([T, eval(X[c], Sol[T])],
                   T = 600 .. 1200, 50),
             c = [CH4, CO2, H2O, H2, CO]),
        title='Frações*molares*dos*compostos*por*variação*de*temperatura')

acer

If the `m~` in your `eqnl1x` is an assumed local then you could try, say,

  globeqnl1x := convert(eqnl1x, `global`):

# and then

  eval(globeqnl1x, [`m~`=1]);

# or

  subs( `m~`=1, globeqnl1x );

Or you could try and pick out the locals of `eqnl1x` using the `indets` command, and figure out which one equals the local `m~` (by testing for equality with global :-`m~` after conversion to `global`, perhaps) and assign that to a new name to use instead for the substitution process. Ie,something perhaps like,

usem := select(u->convert(u,`global`)=:-`m~`,indets(eqnl1x,`local`))[1];
subs( usem=1, eqnl1x );

acer

For question 1, you have forgotten to load DocumentTools, or to call it as DocumentTools:-SetProperty, in the Startup Code region.

For question 2, add the option,

  refresh=true

to the SetProperty command. Ie, change,

   SetProperty(Button1, enabled, false);

to

   SetProperty(Button1, enabled, false, refresh=true);

acer

In 17.02 I see the described behaviour.

If I put another static single plot into the Plot0 component then it again needs two presses of the Button in order to start the animation playing. The same holds if I recompute `dis`.

But if I replace that call to DocumentTools:-Do with,

   SetProperty(Plot0, value, dis, refresh=true);

then it seems to always start playing on the first Button press.

acer

If your complaint is that not all the twenty-seven entries in the result themselves have three entries then the error is yours, not Maple's. You are using sets with {} while it seems that you need lists [] instead. With sets duplicates will not appear (and the triples are also sorted, btw).

seq([round(x11[k]), round(y11[k]), round(z11[k])], k = 1 .. 27);

acer

restart:                     

ineq:=(3-x-sqrt(5-x^2))/(cos((2*x-7)/4)-cos((x-5)/4))>=0:          

convert(simplify([solve(ineq)]),tan);                              

                                                           1/2
               [RealRange(1, Open(2)), RealRange(Open(2), 5   )]

acer

The `subs` command offers simultaneous substitution.

f:= x1 * x2 * x3^4;

                                   4
                           x1 x2 x3 

subs({x1=x3,x3=x1},f);

                                   4
                           x3 x2 x1 

You can compare that against the sequential substitution,

subs(x1=x3,x3=x1,f);

                               5   
                             x1  x2

acer

This is Maple 17.02 64bit on Windows 7 Pro.

restart:

ee:=sin(Pi*(x+1)/(4*x^2-4*x+2))=cos(Pi*(x-2)/(4*x^2-4*x+2)):

S:=[solve(convert(convert(ee,cos),expln),x)]:

seq(print(s), s in S);

                        /3        1       (1/2)\       
                      I |- I Pi + - I Pi 5     | + 2 Pi
                        \2        2            /       
                      ---------------------------------
                                     Pi      
          
                        /3        1       (1/2)\       
                      I |- I Pi - - I Pi 5     | + 2 Pi
                        \2        2            /       
                      ---------------------------------
                                     Pi    
            
                                      1

                                      1

evalf(S);

                    [-0.6180339884, 1.618033988, 1., 1.]

simplify(S);

                     [1   1  (1/2)  1   1  (1/2)      ]
                     [- - - 5     , - + - 5     , 1, 1]
                     [2   2         2   2             ]

[seq(simplify(eval(ee,x=s)), s=S)];

     [    /1     / (1/2)    \\      /1     /     (1/2)\\  
     [-sin|-- Pi \5      - 3/| = cos|-- Pi \3 + 5     /|, 
     [    \12                /      \12                /  

          /1     /     (1/2)\\      /1     / (1/2)    \\              ]
       sin|-- Pi \3 + 5     /| = cos|-- Pi \5      - 3/|, 0 = 0, 0 = 0]
          \12                /      \12                /              ]

map((lhs-rhs)@expand,%);

                                [0, 0, 0, 0]

[solve(convert(convert(ee,cos),expln),x,allsolutions)];

                 [    /             1        1     (1/2)\   
                 [2 I |-I Pi _Z5~ - - I Pi + - (%1)     |   
                 [    \             4        4          /   
                 [---------------------------------------,  
                 [            Pi (4 _Z5~ + 1)               
                 [                                          
                                                            
                       /             1        1     (1/2)\  
                   2 I |-I Pi _Z5~ - - I Pi - - (%1)     |  
                       \             4        4          /  
                   ---------------------------------------, 
                               Pi (4 _Z5~ + 1)              
                                                            
                                                            
                     /              3        3     (1/2)\   
                   2 |3 I Pi _Z4~ + - I Pi + - (%2)     |   
                     \              2        2          /   
                   --------------------------------------,  
                                           (1/2)            
                            3 I Pi + 6 (%2)                 
                                                            
                     /              3        3     (1/2)\]  
                   2 |3 I Pi _Z4~ + - I Pi - - (%2)     |]  
                     \              2        2          /]  
                   --------------------------------------]  
                                           (1/2)         ]  
                            3 I Pi - 6 (%2)              ]  
                                                            
                                                            
                            2     2        2            2   
                 %1 := 16 Pi  _Z5~  - 16 Pi  _Z5~ - 5 Pi    
                           2     2       2                  
                 %2 := 4 Pi  _Z4~  + 2 Pi  _Z4~             

Amusingly,

solve(convert(convert(ee,sin),expln),x); # whoops
Error, (in Engine:-Dispatch) not implemented yet: 5

acer

Three popular choices for trying to find all roots in a finite real range are to use Student:-Calculus1:-Roots (which calls fsolve repeatedly with its `avoid` option), RootFinding:-Analytic, or to repeatedly call RootFinding:-NextZero.

Below, the original problem is used, but for a larger domain of x=0 to x=100.

Note that, with default settings at least, the fsolve approach finds fewer solutions. I would guess that for a large enough right end-point the extreme steepness of the mathematical function between the upper roots would cause `NextZero` to falter as well. It may not be an issue for this particular problem, but the RootFinding:-Analytic approach can messy if there are roots very close to the real line, since it can be difficult to distinguish which are valid but unwanted nonreal solutions and which are wanted purely real solutions which just happen to have been approximated with very small but nonzero imaginary components due to roundoff error.

restart:

findroots:=proc(expr,a,b,{guard::posint:=5,maxtries::posint:=50})
local F,x,sols,i,res,start,t;
   x:=indets(expr,name) minus {constants};
   if nops(x)>1 then error "too many indeterminates"; end if;
   F:=subs(__F=unapply(expr,x[1]),__G=guard,proc(t)
      Digits:=Digits+__G;
      __F(t);
   end proc);
   sols,i,start:=table([]),0,a;
   to maxtries do
      i:=i+1;
      res:=RootFinding:-NextZero(F,start,
                                 'maxdistance'=b-start);
      if type(res,numeric) then
         sols[i]:=fnormal(res);
         if sols[i]=sols[i-1] then
            start:=sols[i]+1.0*10^(-Digits);
            i:=i-1;
         else
            start:=sols[i];
         end if;
      else
         break;
      end if;
   end do;
   op({entries(sols,'nolist')});
end proc:

CodeTools:-Usage( findroots(exp(x)*cos(x)+1, 0, 100) );
memory used=0.55MiB, alloc change=0 bytes, cpu time=47.00ms, real time=33.00ms

1.746139530, 4.703323759, 7.854369686, 10.99555751, 14.13716766, 17.27875956, 

  20.42035224, 23.56194490, 26.70353755, 29.84513020, 32.98672286, 

  36.12831551, 39.26990816, 42.41150082, 45.55309347, 48.69468613, 

  51.83627878, 54.97787143, 58.11946409, 61.26105674, 64.40264939, 

  67.54424205, 70.68583470, 73.82742735, 76.96902001, 80.11061266, 

  83.25220532, 86.39379797, 89.53539062, 92.67698328, 95.81857593, 98.96016858

nops({%});
                                     32
restart:

CodeTools:-Usage( RootFinding[Analytic](exp(x)*cos(x)+1=0, re=0..100, im=-1..1) );
memory used=23.34MiB, alloc change=24.00MiB, cpu time=343.00ms, real time=341.00ms

 48.6946861306418, 45.5530934770530, 42.4115008234622, 39.2699081698730, 

   29.8451302091029, 73.8274273593600, 70.6858347057710, 67.5442420521805, 

   64.4026493985910, 61.2610567450010, 86.3937979737195, 83.2522053201305, 

   80.1106126665395, 76.9690200129500, 92.6769832808990, 89.5353906273097, 

   95.8185759344885, 98.9601685880785, 54.9778714378215, 51.8362787842320, 

   58.1194640914110, 23.5619449018649, 10.9955575115013, 20.4203522496875, 

   32.9867228626928, 26.7035375555158, 36.1283155162826, 7.85436968657417, 

   4.70332375945224, 14.1371676661008, 17.2787595634161, 1.74613953040801


nops([%]);
                                     32

restart:

asolve := proc(ex, var :: name, rng :: range, {avoid :: set := {}})
local avoids,ends,i,sols;
    sols := [fsolve](ex, var, rng, _options['avoid']);
    if sols = [] or not sols :: 'list(numeric)' then
        return avoid;
    else
        ends := [lhs(rng), op(sort(sols)), rhs(rng)]; # sols already sorted?
        avoids := {op(avoid),map2(`=`,var,sols)[]};
        {seq(op(thisproc(ex,var,ends[i-1]..ends[i], ':-avoid' = avoids))
             , i = 2 .. nops(ends))};
    end if;
end proc:

CodeTools:-Usage( asolve(exp(x)*cos(x)+1, x, 0..100) );
memory used=89.20MiB, alloc change=28.00MiB, cpu time=1.36s, real time=1.37s

   {x = 1.746139530, x = 4.703323759, x = 7.854369687, x = 10.99555751, 

     x = 14.13716767, x = 17.27875956, x = 20.42035225, x = 23.56194490, 

     x = 26.70353756, x = 29.84513021, x = 32.98672286, x = 36.12831552, 

     x = 39.26990817, x = 42.41150082, x = 45.55309348, x = 48.69468613, 

     x = 51.83627878}

nops(%);
                                     17
restart:
CodeTools:-Usage( Student:-Calculus1:-Roots(exp(x)*cos(x)+1,x=0..100,numeric) );
memory used=87.17MiB, alloc change=28.00MiB, cpu time=1.36s, real time=1.36s

[1.746139530, 4.703323759, 7.854369687, 10.99555751, 14.13716767, 17.27875956, 

  20.42035225, 23.56194490, 26.70353756, 29.84513021, 32.98672286, 

  36.12831552, 39.26990817, 42.41150082, 45.55309348, 48.69468613, 51.83627878

  ]

nops(%);
                                     17

acer

You could try using the Basis command instead.

with(LinearAlgebra):

A:=Matrix([[-3,6,-1,1-7],[1,-2,2,3,-1],[2,-4,5,8,-4]]);

                               [-3   6  -1  -6   0]
                               [                  ]
                          A := [ 1  -2   2   3  -1]
                               [                  ]
                               [ 2  -4   5   8  -4]

Basis({seq(A[..,i],i=1..ColumnDimension(A))});

                             /[-3]  [-1]  [-6]\ 
                             |[  ]  [  ]  [  ]| 
                            < [ 1], [ 2], [ 3] >
                             |[  ]  [  ]  [  ]| 
                             \[ 2]  [ 5]  [ 8]/ 

Use the menu item Edit -> Split or Join.

It has the keyboard shortcut of F3 (on MS-Windows at least).

acer

Did you intend y(x)^M instead of y^M?

restart:
eq1:=diff(y(x),x$2)+2/x*(diff(y(x),x))+y(x)^M=0:
ic:=y(0)=a,D(y)(0)=0:
p:=dsolve(eval({eq1,ic},[a=1,M=3]), y(x),numeric,output=listprocedure):
Y:=eval(y(x),p):
plot(Y,0..500);

Two basic approaches to plotting a surface from 3D data are interpolation and smoothing. In the former, the surface goes through the data points exactly.

Your "grid" of data points is not full. There are gaps. If you had a full grid (lattice) of x-z data points then plots:-surfdata would handle it quickly, to interpolate a surface.

Stock Maple does not presently have a command to interpolate (higher than linearly) an irregularly spaced set of 3D data points to get a smooth surface. The `surfdata` command can produce a collection of polygon plots as a linear interpolation. But it's not very attractive, in part because of shading and partly because it's only piecewise smooth.

I converted your data to csv, after chopping off the first row of the spreadsheet.

restart:
M:=ImportMatrix("y0.csv",source=csv,datatype=float[8]):

For reasons I don't fully understand, `surfdata` sometimes stalls while trying to handlt the full 383x3 Matrix. I split it into parts, manually. (.. and even then, sometimes it would hang, and then immediately retrying the problematic call would immediately succeed. Weird.)

P1:=plots:-surfdata(M[1..162],0.0..0.4,0.05..1.0):
P2:=plots:-surfdata(M[142..225],0.45..0.55,0.0..1.0):
P3:=plots:-surfdata(M[205..315],0.60..0.80,0.0..1.0):
P3a:=plots:-surfdata(M[298..336],0.80..0.85,0.0..1.0):
P4:=plots:-surfdata(M[316..],0.85..1.0,0.0..1.0):
plots:-display(P1,P2,P3,P3a,P4);

A simpler, if slower and more computationally intensive approach is to do "lowess" smoothing. This has quite a few options to it, but the following seems not too bad, and the outliers don't seem to be painfully far from the surface.

Statistics:-ScatterPlot3D(M,lowess=true,bandwidth=0.15,fitorder=2,showpoints=true);

Yet another approach would be interpolate repeatedly in just 1 dimension, using the original data, so as to form a full grid (Matrix). For example, for just one portion, to turn this,

M[110..125,1..3];
         [0.300000000000000                  0.  -60.3200000000000]
         [                                                        ]
         [0.300000000000000  0.0500000000000000  -62.8000000000000]
         [                                                        ]
         [0.300000000000000   0.100000000000000  -63.6600000000000]
         [                                                        ]
         [0.300000000000000   0.150000000000000  -71.2700000000000]
         [                                                        ]
         [0.300000000000000   0.200000000000000  -60.2500000000000]
         [                                                        ]
         [0.300000000000000   0.250000000000000  -56.1800000000000]
         [                                                        ]
         [0.300000000000000   0.300000000000000  -49.9900000000000]
         [                                                        ]
         [0.300000000000000   0.500000000000000  -53.5200000000000]
         [                                                        ]
         [0.300000000000000   0.550000000000000  -47.0100000000000]
         [                                                        ]
         [0.300000000000000   0.600000000000000  -57.0500000000000]
         [                                                        ]
         [0.300000000000000   0.650000000000000  -56.8900000000000]
         [                                                        ]
         [0.300000000000000   0.700000000000000  -56.7300000000000]
         [                                                        ]
         [0.300000000000000   0.750000000000000  -55.5200000000000]
         [                                                        ]
         [0.300000000000000   0.850000000000000  -50.2100000000000]
         [                                                        ]
         [0.300000000000000   0.950000000000000  -56.4100000000000]
         [                                                        ]
         [0.300000000000000                  1.  -60.3200000000000]

into this,

Matrix([Vector(21,0.3),
        Vector(21,i->(i-1)*0.05),
        CurveFitting:-ArrayInterpolation(M[110..125,2..3],
                                         Vector(21,i->(i-1)*0.05))],
        datatype=float[8]);
         [0.300000000000000                  0.  -60.3200000000000]
         [                                                        ]
         [0.300000000000000  0.0500000000000000  -62.8000000000000]
         [                                                        ]
         [0.300000000000000   0.100000000000000  -63.6600000000000]
         [                                                        ]
         [0.300000000000000   0.150000000000000  -71.2700000000000]
         [                                                        ]
         [0.300000000000000   0.200000000000000  -60.2500000000000]
         [                                                        ]
         [0.300000000000000   0.250000000000000  -56.1800000000000]
         [                                                        ]
         [0.300000000000000   0.300000000000000  -49.9900000000000]
         [                                                        ]
         [0.300000000000000   0.350000000000000  -50.8725000000000]
         [                                                        ]
         [0.300000000000000   0.400000000000000  -51.7550000000000]
         [                                                        ]
         [0.300000000000000   0.450000000000000  -52.6375000000000]
         [                                                        ]
         [0.300000000000000   0.500000000000000  -53.5200000000000]
         [                                                        ]
         [0.300000000000000   0.550000000000000  -47.0100000000000]
         [                                                        ]
         [0.300000000000000   0.600000000000000  -57.0500000000000]
         [                                                        ]
         [0.300000000000000   0.650000000000000  -56.8900000000000]
         [                                                        ]
         [0.300000000000000   0.700000000000000  -56.7300000000000]
         [                                                        ]
         [0.300000000000000   0.750000000000000  -55.5200000000000]
         [                                                        ]
         [0.300000000000000   0.800000000000000  -52.8650000000000]
         [                                                        ]
         [0.300000000000000   0.850000000000000  -50.2100000000000]
         [                                                        ]
         [0.300000000000000   0.900000000000000  -53.3100000000000]
         [                                                        ]
         [0.300000000000000   0.950000000000000  -56.4100000000000]
         [                                                        ]
         [0.300000000000000                  1.  -60.3200000000000]

If that were done for all the sets of x-values, then (only) all the final y-column results could be put into just a single Matrix which could be fed to `surfdata` (and the x- and z-ranges supplied as simple range arguments). I haven't done this.

acer

First 245 246 247 248 249 250 251 Last Page 247 of 336