acer

32343 Reputation

29 Badges

19 years, 327 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

If you open the Cloud palette in Maple itself (left panel), and log in to the Cloud from that, then you should be able to right-click on its entry in the private group and get a popup menu with a "delete" choice.

acer


 

restart;

ee := u*(BesselJ(0,u)^2 + BesselJ(1,u)^2) = 2*BesselJ(0,u)*BesselJ(1,u);

u*(BesselJ(0, u)^2+BesselJ(1, u)^2) = 2*BesselJ(0, u)*BesselJ(1, u)

Digits:=15:

fsolve( ee, u=1-3*I .. 15+3*I, complex );
evalf[30](eval( (rhs-lhs)(ee), u=% ));

4.46629854858362-1.46747037233377*I

-0.267718207452668e-14-0.3165012479938534e-14*I

sols := RootFinding:-Analytic( (rhs-lhs)(ee), u=-15-3*I .. 15+3*I );

0.6e-9, -0.4e-7, 0.2e-7+0.4e-7*I, -4.46629854858362-1.46747037233378*I, -4.46629854858362+1.46747037233378*I, -7.69410395105610-1.72697153718856*I, -10.8745744883790-1.89494334622134*I, -7.69410395105610+1.72697153718856*I, -10.8745744883790+1.89494334622134*I, -14.0388913115431-2.02006279566190*I, -14.0388913115431+2.02006279566190*I, 7.69410395105610-1.72697153718856*I, 10.8745744883790-1.89494334622134*I, 7.69410395105610+1.72697153718856*I, 10.8745744883790+1.89494334622134*I, 14.0388913115431-2.02006279566190*I, 14.0388913115431+2.02006279566190*I, 4.46629854858362-1.46747037233378*I, 4.46629854858362+1.46747037233378*I

seq( evalf[30]((rhs-lhs)(ee)), u=[sols] );

-0.27000000000e-28, 0.80000000000000e-23, 0.110000000000000e-22+0.20000000000000e-23*I, -0.916640078696539e-14-0.2081286559231727e-14*I, -0.916640078696539e-14+0.2081286559231727e-14*I, -0.193035011464111e-14-0.272336139113582543e-13*I, 0.498664204472203e-14-0.104441579826453566e-13*I, -0.193035011464111e-14+0.272336139113582543e-13*I, 0.498664204472203e-14+0.104441579826453566e-13*I, 0.1435733768169201e-13+0.298565617091312014e-13*I, 0.1435733768169201e-13-0.298565617091312014e-13*I, 0.193035011464111e-14-0.272336139113582543e-13*I, -0.498664204472203e-14-0.104441579826453566e-13*I, 0.193035011464111e-14+0.272336139113582543e-13*I, -0.498664204472203e-14+0.104441579826453566e-13*I, -0.1435733768169201e-13+0.298565617091312014e-13*I, -0.1435733768169201e-13-0.298565617091312014e-13*I, 0.916640078696539e-14-0.2081286559231727e-14*I, 0.916640078696539e-14+0.2081286559231727e-14*I

plots:-display(
  plots:-pointplot3d(map([Re,Im,0],[sols]),color=red,symbolsize=20),
  plots:-complexplot3d( (rhs-lhs)(ee), u=-15-3*I .. 15+3*I, grid=[41,41], view=0..1 )
);

 


 

Download besselthing.mw

acer

This sounds like a scenario for which one (or more) module based packages are suitable, saved to a .mla archive that is automatically in your libname.

By having the commands inside a package (named, say, MiscUtils or what have you) then the individual command names are still otherwise available to you unless you load the package(s) using the with command. But it is still easy to get them in any session, without having to remember some long, host-specific, source location string. That's a big advantage of modules, they give you control over the global name space.

I strongly suggest using LibraryTools:-Create and LibraryTools:-Save instead of savelib (especially since casual use of the latter without a specified archive can result in accidental littering of currentdir with errant .m files).

You only have to write the code which rebuilds the .mla archive once. Then you can re-use it each time you edit any of the sources.

If you place the .mla archive inside the file location (string) that the following command returns then its contents will be available in any wholly new session. Maple knows to add this to libname upon (completely new) launch. I use the name MiscUtils here just as an example.

cat(kernelopts(':-homedir'),"/maple/toolbox/MiscUtils/lib");

You can also make the location be version-specific. Eg,

cat(kernelopts(':-homedir'),"/maple/toolbox/2016/MiscUtils/lib");

Note that the forward slash "/" is understood across platforms (Linux, Windows, OSX), by Maple commands in the LibraryTools and FileTools packages.

So, a piece of re-usable build-code can form that string, concatenate with the name of (one or more) .mla filenames, and be used by LibraryTools commands.

You can also place .hdb or .help archives (Help databases) in the same locations.

Note that the GUI will also need a complete relaunch in order to pick up any Help files thus placed, after the first time the folder is created. But you don't have to mess around with manually adding any location to libname, or fiddling with in any initialization file.

So, you can get automatic access in new sessions by saving your procedues to a toolbox location, and by using package(s) your global name space is not cluttered (unless you choose to load a package).

acer

1) Upload the worksheet to a public location in the Maple Cloud (you can even do this straight from Maple's Standard GUI). See maplecloud.maplesoft.com .  Or you could set up a private group on that cloud, and allow access to only select members. Even using a web-browser like Chrome allows mouse-pointer rotation of 3D plots rendered in such pages.

2) They could install the MaplePlayer, which is free. It displays .mw and even allows interaction with any Embedded Components you have placed in the sheet (which you can load up with procedures, behind the scenes). This too talks to the Maple Cloud, so you could also upload/download from there. https://www.maplesoft.com/products/maple/Mapleplayer/

acer

The (unquoted) call to Quantile(X,z) returns a generic RootOf. And floating-point approximation of that (using evalf as plot will do) need not always converge to the "same" root (branch). The explanation by vv is very good.


 

restart;

with(Statistics):
U := Distribution(PDF=(t->piecewise(t<-5,0,t< 5,-(1/2000)*t^4+(9/1000)*t^2+7/80, 0))):
X := RandomVariable(U):

plot('Quantile'(X, z, numeric), z = 0 .. 1, adaptive=false, numpoints=30,
                size=[500,200], gridlines=false);

U:=Quantile(X, z);

RootOf(_Z^5-30*_Z^3-875*_Z+10000*z-5000)

[allvalues(U)];

[RootOf(_Z^5-30*_Z^3-875*_Z+10000*z-5000, index = 1), RootOf(_Z^5-30*_Z^3-875*_Z+10000*z-5000, index = 2), RootOf(_Z^5-30*_Z^3-875*_Z+10000*z-5000, index = 3), RootOf(_Z^5-30*_Z^3-875*_Z+10000*z-5000, index = 4), RootOf(_Z^5-30*_Z^3-875*_Z+10000*z-5000, index = 5)]

evalf( eval(%,z=0.2) );

[HFloat(7.337832818846145), HFloat(0.9188750749042348)+HFloat(4.672740913616434)*I, HFloat(-2.849847210142789), HFloat(-6.325735758511826), HFloat(0.9188750749042348)-HFloat(4.672740913616434)*I]

plot([allvalues(U)][1..4],z=0..1, gridlines=false);

 


 

Download dist1.mw

acer

Do you actually have a Matrix with floats? (The Matrix you mentioned will have exact integer entries.) Do you understand that Maple may have to do a lot more work to get an exact result. At the very least make sure that the entries of the Matrix are floats.

It's not sensible to compare with Matlab unless you're using floats and working with hardware floats (because that's all Matlab alone can do). For comparison with Matlab use Matrices/Vectors with datatype=float[8] and keep Digits<=15 and ensure that the environment variable UseHardwareFloats is not set to false.

Your suppositions about the computational complexity are misguided. That's not what big-O (or little-o) notation means.

acer

Do you consider the following as mathematically acceptable? (Note that everything below is in 1D Maple Notation.)

> Physics:-diff( diff(a(t), t)*a(t), a(t) ):

> lprint(%);
diff(a(t),t)
If so, then are you looking for something like this?
> restart;

> expr2 := a(t)*b(t)+2*(diff(a(t), t))*(diff(b(t), t))*c(t):

> S2 := frontend(int, [expr2,a(t)]):

> lprint(S2);
2*diff(a(t),t)*diff(b(t),t)*c(t)*a(t)+1/2*a(t)^2*b(t)

> Physics:-diff( S2, a(t) ):

> lprint(%);
a(t)*b(t)+2*diff(a(t),t)*diff(b(t),t)*c(t)

> expr2 - Physics:-diff( S2, a(t) );

                                    0
Alternatively, by freezing instead of using `frontend`,
> AltS2 := thaw( int( subs([diff(a(t),t)=freeze(diff(a(t),t)),
                            a(t)=freeze(a(t))],
                           expr2),
                      freeze(a(t)) ) ):

> lprint(AltS2);
2*diff(a(t),t)*diff(b(t),t)*c(t)*a(t)+1/2*a(t)^2*b(t)

> expr2 - Physics:-diff(AltS2, a(t));

                                     0

acer

If you just want to get something printed then here is a stab at it, though it relies on using a function call (and so itn't automatic, like PDEtools:-declare offers). Perhaps there is something easier, with only PDEtools or Physics. (It's not terribly sophisticated. As written it doesn't allow you to change from `U` to something else, on the fly. But if printing with a function call is adequate for your purpose then you could adjust it.)


 

restart;

eqn := diff(f(x),x) = diff(U(g(x)),x);

diff(f(x), x) = (D(U))(g(x))*(diff(g(x), x))

neweqn := diff(P(z),z) = diff(U(w(z)),z);

diff(P(z), z) = (D(U))(w(z))*(diff(w(z), z))

PDEtools:-declare(':-quiet'):

Print:=module()
       export SetVar;
       local ModuleApply, var;
       var:=':-x';
       ModuleApply:=proc(ee)
         print(subsindets(ee, specfunc(anyfunc(identical(var)),D(U)),
                          u->diff(U(op(0,op(u))),op(0,op(u))), ee));
         NULL;
       end proc:
       SetVar:=proc(v::symbol) var:=v; NULL: end proc;
end module:

Print(eqn);

diff(f(x), x) = (diff(U(g), g))*(diff(g(x), x))

Print:-SetVar(z);

Print(neweqn);

diff(P(z), z) = (diff(U(w), w))*(diff(w(z), z))

 


 

Download pardiff.mw

acer

restart;

# Method 1, handling just a pair of inequalities.
S := {t<=2.3, .01 < t}:
P := And( op(S) ):
RR := convert( P, RealRange );
`..`( op(subsindets(op(2,RR),specfunc(Open),op)) );

# Method 2, allowing `solve` to do it.
SR := solve( P, t );
`..`( op(subsindets(SR,specfunc(Open),op)) );

# So here we go... method 1.
func := proc(s::set({`<`,`<=`}))
  `..`( op(subsindets(op(2,convert( And( op(s) ), RealRange )),specfunc(Open),op)) );
end proc:

sols := [{theta <= Pi-arccos(-3/4+(1/4)*sqrt(13+16*sqrt(2))),
          arccos(3/4) < theta},

         {arccos(-3/4+(1/4)*sqrt(13+16*sqrt(2)))+Pi <= theta,
          theta < 2*Pi-arccos(3/4)},

         {theta <= 3*Pi-arccos(-3/4+(1/4)*sqrt(13+16*sqrt(2))),
          2*Pi+arccos(3/4) < theta}]:

map( func, sols );

evalf(%);

# A slightly harder case, which method 2 handles a bit better.
S2 := {t<=2.3, .01<t, t<1.8}:
SR2 := solve( And( op(S2) ), t );
`..`( op(subsindets(SR2,specfunc(Open),op)) );

# And so somewhat more robust...
func2 := proc(s::set({`<`,`<=`}))
  local var := op(1, indets(s,name) minus {constants});
  `..`( op(subsindets(solve( And( op(s) ), var),specfunc(Open),op)) );
end proc:

map( func2, sols );

evalf(%);

acer

This is intended to be pasted in as 1D Maple Notation code.
restart;

G:=proc(P,{usedots::truefalse:=false},$)
  local part1,part2,rep;
  uses Typesetting;
  rep:=RepeatingPart(P);
  part1:=mn(cat(`if`(IntegralPart(P)=0 and Sign(P)=-1,"-",NULL),
                 Sign(P)*IntegralPart(P),".",NonRepeatingPart(P)[]));
  if usedots then
    part2:=mover(mn(sprintf("%a",rep[1])),
                    mo("&middot;",':-fontweight'="bold")),
             `if`(nops(rep)>2,mn(cat(rep[2..-2][])),NULL),
             `if`(nops(rep)>1,
                  mover(mn(sprintf("%a",rep[-1])),
                        mo("&middot;",':-fontweight'="bold")),NULL);
  else
    part2:=mover(mn(convert(cat(rep[]),string)),
                 mo("&conjugate0;"));
  end if;
  return mrow(part1,part2);
end proc:

p := NumberTheory:-RepeatingDecimal(-1234/70);
G(p);
G(p, usedots=true);

p := NumberTheory:-RepeatingDecimal(1/3);
G(p);
G(p, usedots=true);

p := NumberTheory:-RepeatingDecimal(1/33);
G(p);
G(p, usedots=true);

p := NumberTheory:-RepeatingDecimal(-11/17);
G(p);
G(p, usedots=true);

acer

Try adding the option spacestep=0.25 to those three calls to pdsolve.

Also, it seems you may be able to get better performance out of it if you set up and use those partial derivatives more like this:

Fy:=x0 -> eval(f,pds:-value(f,x=x0,output=listprocedure)):
F2y:=x0 -> eval(f,pds2:-value(f,x=x0,output=listprocedure)):
F3y:=x0 -> eval(f,pds3:-value(f,x=x0,output=listprocedure)):

plot([D[1](Fy(1.0)), D[1](F2y(1.0)), D[1](F3y(0.0))],
     0..20, color=[red,blue,green] );

acer

After just,

K:=ExcelTools:-Import("C:\\Assignment 2.xlsx", "Q2", "V7:AF17");

you may find that K is 2-dimensional Array (1..11 by 1..11).

The try either,

kkk:=convert(K, Matrix);

or,

kkk:=Matrix(K);

And then try the MatrixInverse command from the LinearAlgebra package, as you were using it before.

acer

If you have Maple version 18 or later then you could try the InertForm package. Eg,

with(InertForm):

expr := Parse( "4 + sqrt(9) = x - 1" ):

Display( expr, inert=false );

Value( expr );

The InertForm commands have been used (internally) in the Student:-Basics:-ExpandSteps command that was also new in Maple 18.

acer

If I recall, in another recent Question by the same member, the listprocedure output from dsolve/numeric is used subsequently in assignments to the very names used in the DE system.

Now, if the listprocedure output from dsolve were used to assign a solution procedure to the name `x` and furthermore if, without restart, the OP then retried the call to dsolve with the stated new initial condition, then the cited error message would attain. I suspect that this is what's happened.

Running the code (similar to what's in in Tom's Answer, say, but with itermediate assignment to `x`), *without* the restart between the dsolve calls, would show the problem. Ie. in the second attempt to call dsolve the intended IC is x(0) which evaluates to 3.0 because x has been assigned the solution proc from the first call. See the following attachment.

dsprob.mw

If that's the simple problem here, then I suggest using different names in the DE system (passed to dsolve) than those used in the subsequent assignments.

acer

I agree with you that the current behavior is not right. The units for the dependent axis label should be deduced by the plotting command by taking into account the units supplied in the range supplied for the independent variable.

Sure, there may be difficult cases to figure out (eg. units buried in piecewise, etc), but Maple should ideally be up to the task. Having to force the label for the dependent axis by using the useunits=list with explicit units for the second entry puts the burden on the user to do the extra work, and is not so friendly.

For many examples where it'd be easier/feasible to have the plotting command do the heavy lifting, the basic approach (done internally, autmatically) might include an attempt something like the following. Note that while I have used the useunits=list option I have not had to figure out myself, explicitly, what the units wil be for the dependent axis.

(Please excude the double-fencing of the units in the images below. That's due to how this site inlines worksheets. In the actual Maple 2016 GUI the labels appear with the unit symbols proper.)

 

restart;

plots:-setoptions(gridlines=false, size=[400,150]):

A := 13*Unit(m^2/s);

13*Units:-Unit(('m')^2/('s'))

# You may wish to not "attach" a unit to `r` just yet.
# That should be your prerogative.

expr := A*r;

13*Units:-Unit(('m')^2/('s'))*r

depunits := Unit(m);

Units:-Unit('m')

# You don't want this behavior from `plot` (which seems wrong).

plot( expr,
      r = 2*depunits .. 5*depunits );

# You want behavior more like this.

plot( combine(subs(r=r*depunits,expr), units),
      r = 2 .. 5,
      useunits = [depunits, default] );

# So perhaps `plot` should work that out for itself, properly.

 

 depunits3.mw

acer

First 203 204 205 206 207 208 209 Last Page 205 of 336