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

restart:

s := { x>4, y>4 }:

sbar := solve( map( `not`, s ) );

                          sbar := {x <= 4, y <= 4}

convert(s, RealRange);

       {x::(RealRange(Open(4), infinity)), y::(RealRange(Open(4), infinity))}

convert( sbar, RealRange );

             {x::(RealRange(-infinity, 4)), y::(RealRange(-infinity, 4))}

Is is a small list of precomputed primes, used for quick look-up.

restart:
kernelopts(opaquemodules=false):
isprime:-special_primes;

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 

  73, 79, 83, 89, 97, 979073763359, 987715808641, 1203502041253, 987709929361, 

  987714327601, 902164268009, 18945002166578281, 987723662641, 987674160001]

acer

The ssystem command can execute a command on the host OS, and is available across platforms and Maple interfaces.

acer

How about using `isolate` instead of `solve`?

rhs(isolate(Eq1, diff(y1(t), t, t)));

acer

So you working in Matlab, with Maple as the engine for its Symbolic Toolbox, is that right?

And you want results from Maple (invoked from within Matlab) to be printed in the Matlab interface as something which then cut&pastes as 1D Maple Notation input? Is that right?

Perhaps it might help to first issue the (Maple command) interface(prettyprint=0)

acer

Looks like a bug.

Try it instead as,

LinearAlgebra:-Eigenvectors( convert(A,rational) );

I will submit a bug report.

acer

Please describe in as much detail as possible how you want color to be defined.

The code you're shown has procedure mandelbrot which currently returns a single value given input point (x,y). And plot3d is using that to select a hue (as in H=hue from the HSV color space).

With just a single returned value m (per x,y input) it's natural to either produce a grayscale shading value or a hue value. Or you could use m for the intensity (the V in HSV) as well as for the hue.

Another value that you *could* make use of is the final z, for each (x,y) input. Since z is complex its real absolute value abs(z) is another piece is information that can be combined with the final m value to produce a color. With two values (m and abs(z) say) you could produce some attractive color shadings by generating three numbers for the RGB color space. Or you could produce values in a 3-element color space by doing modular arithmetic on either a single or a double-valued return.

Note that I have made no special effort here for efficiency. In particular the 2-value-return version mandelbrot2 below is not evalhf'able and so is slow. It could be made faster.

I didn't understand why you'd want a style=point, so I changed it. See also the last example on the densityplot command's help page. Other related links: herehere, here, and (distantly, showing how images and plot GRID are interchangeable) here and here.

The plots below look much brighter and less grainy in Maple itself.

restart:

mandelbrot := proc(x, y)

     local c, z, m;

     c := evalf(x+y*I);

     z := c;

     for m from 0 to 30 while abs(z) < 2.0 do

        z := z^2+c

        od;

        m;

     end:

plot3d(0, -2 .. 0.7, -1.2 .. 1.2, orientation=[-90,0], grid=[200, 200],
       scaling=constrained, style=patchnogrid, lightmodel=none,
       color=[((x,y)->mandelbrot(x,y)/30.0),
              1,
              1,
              colortype=HSV]);

plot3d(0, -2 .. 0.7, -1.2 .. 1.2, orientation=[-90,0], grid=[200, 200],
       scaling=constrained, style=patchnogrid, lightmodel=none,
       color=[((x,y)->mandelbrot(x,y)/30.0),
              1,
              ((x,y)->30-mandelbrot(x,y)),
              colortype=HSV]);

p1,p2,p3 := 23,5,2:

plot3d(0, -2 .. 0.7, -1.2 .. 1.2, orientation=[-90,0], grid=[200, 200],
       scaling=constrained, style=patchnogrid, lightmodel=none,
       color=[((x,y)->irem(mandelbrot(x,y),p1)),
              ((x,y)->irem(mandelbrot(x,y),p2)),
              ((x,y)->irem(mandelbrot(x,y),p3)),
              colortype=RGB]);

mandelbrot2 := proc(x, y)
     option remember,system, hfloat;

     local c, z, m;

     c := x+y*I;

     z := c;

     for m from 0 to 30 while abs(z) < 2.0 do

        z := z^2+c

        od;

        m, abs(z); # no longer evalhfable, as is

     end:

plot3d(0, -2 .. 0.7, -1.2 .. 1.2, orientation=[-90,0], grid=[200, 200],
       scaling=constrained, style=patchnogrid, lightmodel=none,
       color=[((x,y)->mandelbrot2(x,y)[1]/30.0),
              1,
              ((x,y)->mandelbrot2(x,y)[2]),
              colortype=HSV]);

 


Download naive_mandelbrot.mw

acer

I am having trouble understanding what you want, sorry. Perhaps something like this?

(It's a bug in this server that gridlines are shown in the first plot below.)

restart;

R:=2:

plots:-display(
   plots:-polarplot(R,theta=0..2*Pi,color=red),
   plots:-polarplot(R+cos(theta),theta=0..2*Pi,color=blue),
   gridlines=false);

plots:-display(
   plot(R,theta=0..2*Pi,color=red,coords=polar),
   plot(R+cos(theta),theta=0..2*Pi,color=blue,coords=polar),
   gridlines=false,scaling=constrained);

 


Download costhetafun.mw

acer

You haven't yet said which of the "styles" offered by Matlab's `bar3` command you're trying to emulate. None of these below cover's bar3's `grouped` style, for example.

restart;

Y := Matrix( 20, 3, (i,j)->evalf(1+sin(i*j/Pi)), datatype=float[8] ):

plots:-matrixplot( Y, heights=histogram, gap=0.5,
                   color=((x,y)->1-y/3+0.2),
                   orientation=[-55,55,0], labels=["","",""] );

Statistics:-AreaChart( Y );

Statistics:-AreaChart( Y, format=stacked );

 


Download 3dbarstuff.mw

acer

Try it with a call to `combine` around that problematic expression, ie,

combine( simplify( 2/Pi^2*zabt(n) + 4/Pi^2*dwabt(n) ) );

I am seeing this,

expr := (exp(-n*(cos(phi)+sin(phi)))
         *(-16*n^8+4*sqrt(4*n^2+6*n-4)*sqrt(4*n^2-6*n-4)*n^6+116*n^6
           -13*sqrt(4*n^2+6*n-4)*sqrt(4*n^2-6*n-4)*n^4-236*n^4
           -13*sqrt(4*n^2+6*n-4)*sqrt(4*n^2-6*n-4)*n^2+116*n^2
           +4*sqrt(4*n^2+6*n-4)*sqrt(4*n^2-6*n-4)-16))
        /(sqrt(4*n^2+6*n-4)*sqrt(4*n^2-6*n-4)
          *(sqrt(4*n^2+6*n-4)*sqrt(4*n^2-6*n-4)*n^4-4*n^6
            -3*sqrt(4*n^2+6*n-4)*sqrt(4*n^2-6*n-4)*n^2
            +13*n^4+sqrt(4*n^2+6*n-4)*sqrt(4*n^2-6*n-4)
            +13*n^2-4)):

combine(expr);

                       -exp(-n cos(phi) - n sin(phi))

acer

See here for an old post on this topic.

Altenatively, you could try it like this (and adjust the size as you wish),

Typesetting:-mo("Hello", mathcolor = "#00CC00", mathsize = "28");

acer

You could use the -c option twice. One to push in your single statement, and once more to push in a quit statement.

On MS-Windows the joy of this is often about getting quotes escaped properly.

(There is at least one old thread on this site about scripting with the CLI more generally, but which includes some comments about passing arbitrary input as if from a file.)

acer

I may not be properly understanding your question, but why can't you use square bracket indexing to both retrieve and assign to the exports of the Record?

restart:

q:=Record(a=sin(x),b=cos(x),c=(x+3.0)^2);

                        /                                     2\
             q := Record\a = sin(x), b = cos(x), c = (x + 3.0) /

exports(q);

                                   a, b, c

for e in exports(q) do
  q[e]:=limit(q[e],x=Pi);
end do:

a,b,c;

                                   a, b, c

eval(q);

                   Record(a = 0, b = -1, c = 37.71916033)

It could also be done above with,

  assign( eval(q[e],1), limit(q[e],x=Pi) );

for each export e of the Record.

acer

This is not good.

I merge execution groups (using the F4 key, say) often when programming in 1D mode. And prior to Maple 2015 I've relied on the fact that lines which begin with a prompt and those which don't are not treated differently, as far as multiple line statements go. And now in Maple 2015 this is broken.

This is a serious regression bug. Its cause is new behaviour in the Standard GUI of Maple 2015, in which a 1D Maple Notation input line need not be terminated with either colon or semicolon. I suppose this was intended as a convenience, implemented without giving adequate consideration to the fact that it introduces ambiguity to the language and breaks previously valid syntax.

Here is a simple example. This example of 1D Maple Notation code works in Maple 18 and earlier, but fails with a syntax error in the Standard GUI of Maple 2015. Note that these lines all occur within the same Execution Group.

for i from 1

  to 3 do

  i end do;

Error, `;` unexpected

Download multilineregression.mw

1D Maple Notation programming in an Execution Group of a Worksheet was one of the few (if only) adequately stable, reliable, and usable modes of programming in the Standard GUI.

The OP's plotting example is a good illustration of the kinds of things that are typical usage. Suppose you have three plot calls in three seeparate execution groups. You can merge the execution groups using just F4, with no need for cut & paste. And then remove a few terminators, and wrap in a `print` call, and the plotting's all combined. Easy. No need to mark out long lines wih the mouse cursor. And by having the print call on a separate line it's even easy to undo it, or toggle the merging on and off just by adding a few # symbols. Easy and useful. But now, a previously valid and straightforwardly natural way to accomplish this has been broken.

It might be ok to remove the need for a colon/semicolon terminator at the end of the last line of an Execution Group. But it's very much wrong to have the parser try and execute every line (lacking a colon/semicolon terminator) before the last line of an Execution Group.

acer

convert(BesselJ(0,x),FormalPowerSeries);

                          infinity
                           -----       k  (-k)  (2 k)
                            \      (-1)  4     x
                             )     ------------------
                            /                2
                           -----         (k!)
                           k = 0

acer

First 226 227 228 229 230 231 232 Last Page 228 of 336