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

Here's another way (where evalf/RoofOf will use fsolve, under the hood...), which happens to work for this particular example.

c := x+sin(x)+ln(t):
F := x+x^2:
plot(subs(x=solve(c,x),F),t=0..10,view=-1..6);

I have deliberately gone for simplicity here, rather than efficiency. Other ways are faster. But this is simple.

acer

Yes, you can replace those two calls to ArrayTools:-Copy with a single indexed assignment.

restart;

A := LinearAlgebra:-RandomVector[row](10):
B := Vector[row](10):

B[[2,3,8,9]] := A[[2,3,8,9]]:

B;

                     [0, 27, 8, 0, 0, 0, 0, 92, -31, 0]

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

First 229 230 231 232 233 234 235 Last Page 231 of 339