acer

32632 Reputation

29 Badges

20 years, 46 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

I chose the height for the 2D part to be minz+(minz-maxz)*0.1 using the min and max of the 3D part. It has not meaning, in terms of the expression `ee` that is plotted as the surface. Change that if you wish.

restart:

with(plots):
with(plottools):

ee := sin(x)*y^2:

P3:=plot3d(ee, x=-Pi..Pi, y=-1..1, shading=zhue):
minz,maxz := op(plottools:-getdata(P3)[2][3]);

-1., 1.

P2:=densityplot(-ee, x=-Pi..Pi, y=-1..1, style=surface, colorstyle=HUE):

# The shadings are not an exact match. This is not satisfactory. Read on...

display( P3,
         transform((x,y)->[x,y,minz+(minz-maxz)*0.1])(P2) );

# Here, the shadings match.
# The style of the surface is inherited from that of the densityplot.

display( transform((X,Y)->[X,Y,eval(ee,[x=X,y=Y])])(P2),
         transform((X,Y)->[X,Y,minz+(minz-maxz)*0.1])(P2) );

# Or we could correct the raised surface to have a patch style.

display( subsindets(transform((X,Y)->[X,Y,eval(ee,[x=X,y=Y])])(P2),
                    specfunc(anything,STYLE), u->STYLE(PATCH)),
         transform((X,Y)->[X,Y,minz+(minz-maxz)*0.1])(P2) );

# Or we could create the densityplot with the `patch` style.

P2b:=densityplot(-ee, x=-Pi..Pi, y=-1..1, style=patch, colorstyle=HUE):
display( transform((X,Y)->[X,Y,eval(ee,[x=X,y=Y])])(P2b),
         transform((X,Y)->[X,Y,minz+(minz-maxz)*0.1])(P2b) );

PC:=contourplot(-ee, x=-Pi..Pi, y=-1..1, color=black):

display( subsindets(transform((X,Y)->[X,Y,eval(ee,[x=X,y=Y])])(P2),
                    specfunc(anything,STYLE), u->STYLE(PATCH)),
         transform((X,Y)->[X,Y,minz+(minz-maxz)*0.1])(display(P2,PC)) );

display( transform((X,Y)->[X,Y,eval(ee,[x=X,y=Y])])(P2),
         transform((X,Y)->[X,Y,minz+(minz-maxz)*0.1])(display(P2,PC)) );

display( subsindets(transform((X,Y)->[X,Y,eval(ee,[x=X,y=Y])])(P2),
                    specfunc(anything,STYLE), u->STYLE(PATCHCONTOUR)),
         transform((X,Y)->[X,Y,minz+(minz-maxz)*0.1])(display(P2,PC)) );

 


Download surfcont.mw

acer

Inside your procedure which calls Color(), try either replacing that with ColorTools:-Color() , or add the line uses ColorTools; at the start of the procedure, or put that use...end use inside your procedure.

Does your procedure color_my_rgb call Color?

restart;

f:=proc(nm)
  local c;
  c:=Color(nm);
  c[];
end proc:

# This does not work.
use ColorTools in
  f("Orange");
end use;
                              Color("Orange")[]

restart;

f:=proc(nm)
  local c;
  use ColorTools in
    c:=Color(nm);
  end use;
  c[];
end proc:

f("Orange");
                         1.00000000, 0.64705882, 0.

restart;

f:=proc(nm)
  local c;
    c:=ColorTools:-Color(nm);
  c[];
end proc:

f("Orange");
                         1.00000000, 0.64705882, 0.

restart;

f:=proc(nm)
  uses ColorTools;
  local c;
    c:=Color(nm);
  c[];
end proc:

f("Orange");
                         1.00000000, 0.64705882, 0.

acer

The ImportMatrix command should be able to handle this.

acer

There are several ways to do this. Here are two.

restart:                         

f:=RandomTools:-Generate(list(integer(range=-30..50), 5), makeproc):

seq( f(), i=1..4 );                                                 

    [14, -25, 28, 13, 7], [38, -4, -14, 3, -13], [21, 25, 12, -6, 29],

    [-17, 19, 16, -23, 15]

restart:                                                            

f:=rand(-30..50):                                                   

seq( [seq(f(),j=1..5)], i=1..4 );                                   

    [14, -25, 28, 13, 7], [38, -4, -14, 3, -13], [21, 25, 12, -6, 29],

    [-17, 19, 16, -23, 15]

I expect that there are several faster ways.

I expect that you could also use Statistics:-Sample and a discrete distribution.

Here's another one,

restart:

f:=(n,k)->convert(LinearAlgebra:-RandomMatrix(k,n,generator=-30..50),
                  listlist)[]:

f(5,4);

    [38, 43, 9, 23, 36], [-4, -18, -5, -9, -12], [-22, -24, -5, 14, 21],

    [28, 21, 46, -11, 15]

Do you need it very, very fast? Do you need to create a large number of these lists? Do you need to create them all up front, before you work on them?

acer

Change that last line to this,

plots:-display(p1,p2);

The display comamnd you're trying to use is part of the plots package. Either reference it as plots:-display or first load the package using the command with(plots): and then call it as just display.

acer

Perhaps I don't understand what your trying to accomplish. But why not use exact values for x?

for x from -1 by 0.5 to 1 do print(x, evalf(0^(x^2), 20)) end do; 

                                    -1, 0.

                                   -0.5, 0.

                             0., Float(undefined)

                                    0.5, 0.

                                    1.0, 0.

for x from -1 by 1/2 to 1 do print(x, evalf(0^(x^2), 20)) end do;

                                    -1, 0.

                                   -1/2, 0.

                                     0, 1.

                                    1/2, 0.

                                     1, 0.

for x from -1 by 1/2 to 1 do print(x, evalf(0.0^(x^2), 20)) end do;

                                    -1, 0.

                                   -1/2, 0.

                                     0, 1.

                                    1/2, 0.

                                     1, 0.

And of course there are lots of ways that you can make the behavior conditional upon the value of x. Examples include,

for x from -1 by 0.5 to 1 do
  print(x,`if`(x=0,1.0,evalf(0^(x^2), 20)));
end do;

                                    -1, 0.

                                   -0.5, 0.

                                    0., 1.0

                                    0.5, 0.

                                    1.0, 0.

for x from -1 by 0.5 to 1 do                
  print(x,evalf(0^(`if`(x=0,0,x^2)), 20));
end do;

                                    -1, 0.

                                   -0.5, 0.

                                    0., 1.

                                    0.5, 0.

                                    1.0, 0.

acer

Change the square brackets in the assignment to Eqns (inside plotsol1s) to round brackets.

Round brackets are expression delimiters. Square brackets create a list.

acer

restart:

eq1 :=  x^2-y^2 = a*z^2:
eq2 := x-y = a*z:       

normal(eq1/eq2);        

                                   x + y = z

acer

See this help-page on Maple initialization files.

That file should be a plaintext file (but without .txt as filename extension). It should contain Maple commands in 1D Maple Notation (plaintext).

In this case it should contain a line which redefines the Maple variable libname. For example.

libname:= `c:/maple12/advisor`, libname:

and of course edit that to be the place you actually install it.

acer

Your line of code,

   SetVariables = proc( vars:: list, time )

should be

   SetVariables := proc( vars:: list, time )

so that it is an assignment statement.

Also, the line

   for i from 1 to var N do

in the body of the SetVariables procedure is not valid syntax. It might have been intended as,

   for i from 1 to varN do

acer

restart;

`&as`:=proc(a::uneval) eval(`assuming`([a],[args[2..-1]])); end:

sqrt(x^2) &as (x>0);

                               x

sqrt(x^2) &as (x<0);

                               -x

(sqrt(x^2)*sqrt(y^2)) &as (x>0, y>0);

                              x y

(sqrt(x^2)*sqrt(y^2)) &as (x<0, y>0);

                              -x y

(sqrt(x^2)*sqrt(y^2)) &as (x>0 and y>0);

                              x y

(sqrt(x^2)*sqrt(y^2)) &as (x>0 and y<0);

                              -x y

acer

This weird behaviour seems to have started with Maple 18.00.

restart:

hhh:=400/Unit(1/kg);
                              400       
                       -----------------
                                  / 1  \
                       Units:-Unit|----|
                                  \'kg'/

with(Units:-Standard,`/`,`*`,normal);
                         [/, *, normal]

simplify(hhh);
                     400 Units:-Unit('kg')

normal(hhh); # ???
                                     / 1  \
                     -400 Units:-Unit|----|
                                     \'kg'/

:-normal(hhh);
                              400       
                       -----------------
                                  / 1  \
                       Units:-Unit|----|
                                  \'kg'/

hhh;
                              400       
                       -----------------
                                  / 1  \
                       Units:-Unit|----|
                                  \'kg'/

1/hhh; # ???
                       1                   
                    - --- Units:-Unit('kg')
                      400                  

hhh/1; # ???
                                     / 1  \
                     -400 Units:-Unit|----|
                                     \'kg'/

I will submit a bug report.

acer

Is it a part of your problem that Maple is parsing your input as if it were multiplication, ie, like D(F) * (x) ?

If so and if you are using Maple 2015 then this might be related to the GUI preference for so-called Smart Operators.

acer

@Tycoon51 If plots:-matrixplot satisfies your needs then great. You did state that you wanted the x- and y-axes to be coordinates of the 2-dimensional "array".

It may be worth mentioning that sometimes one wants the coordinate values to be interpreted as if from some pair of x- and y-ranges, rather than just as discrete coordinate values. In such cases the command plots:-surfdata can help, as it also accepts optional arguments to specifiy the x- and y-ranges to be used for generating x- and y-axis tickmarks.

A:=Matrix(1..51, 1..31, (i,j)->evalf( ((j-1-15)*2/30)^2 * sin(2*Pi*(i-1)/50)) ):

plots:-matrixplot(A, axes=box);

plots:-surfdata(A, 1..51, 1..31, axes=box);

plots:-surfdata(A, 0..2*Pi, -1..1, axes=box);

Why do you need each entry to be read back in as an individual assignment statement?

Why not use ExportMatrix to write all the entries to a file at once, after the loop finishes? And then import then all at once using ImportMatrix in your new sessions?

If you prefer you could still export each entry individually using fprintf (or other) inside the loop. But you could still re-import them in bulk, using ImportMatrix (which should be faster as well as simpler).

You can make the call to ImportMatrix be done with a single assignment. Eg,

M := ImportMatrix(outfile,...)

So in this way you can have your values be in a data file, rather than in a file of Maple commands.

acer

First 220 221 222 223 224 225 226 Last Page 222 of 339