12769 Reputation

29 Badges

11 years, 26 days

On google groups. (comp.soft-sys.math.maple and sci.math.symbolic)

On stackoverflow.


MaplePrimes Activity

These are answers submitted by 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.)



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))


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


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



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






# 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 );


# 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 );



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

  local part1,part2,rep;
  uses Typesetting;
  part1:=mn(cat(`if`(IntegralPart(P)=0 and Sign(P)=-1,"-",NULL),
  if usedots then
  end if;
  return mrow(part1,part2);
end proc:

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

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

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

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


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] );


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);



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


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


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.


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.

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.


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.)



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

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


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

expr := A*r;


depunits := 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.


I really don't approve of the extensive, nested, use of operators in the manner in you have coded this (passing ony t for each call). It makes your computations repeat the same function calls many, many times. For example, just to compute three frames of the animatiion r1 is called about 580000 times.

There is also the problem of duplication where a vector-valued procedure (operator) is called 3 times inside another, outer procedure as all of, say, f(t)[1], f(t)[2], f(t)[3] .

And the nesting of calls within calls makes the overall effect on performance be cumulative.

It seems like a lot of time savings may be had by giving several of the key procedures option remember.

Better would be a complete rewrite, IMO, in another programming style. There may well be another factor of ten (or several) to be gained. But perhaps this helps you, for now. Double check the correctness of the numeric results, compared to the original, of course.


I think I see the problem, or part of it at least...

The convert(...,units,...) accepts an option symbolic=true which allows it to ignore the difference between m and m(radius) (ie. it allows convert to treat arclength and length as having the being the same kind of dimension).


B := 2*Unit(km*deg);


# You don't want this error
convert(B, units, m);

Error, (in convert/units) unable to convert `km*arcdeg` to `m`

combine(B, units);


# ...nor this one.
convert(combine(B,units), units, m);

Error, (in convert/units) unable to convert `m^2/m(radius)` to `m`

# The magic.
convert(B, units, m, symbolic=true);



But unfortunately that conversion requires that you know in advance what the target unit is, so it's not helpful here. And the combine(...,units) command doesn't accept a similar option.

It is possible to write a procedure that acts like combine(...,units) but which gets a similar benefit.


R := proc(e)
 local res;
   res := combine(e, ':-units');
   # Help cases like x+y*Unit(...) when Units:-Standard is not loaded.
   res := subsindets(e, 'specfunc(Units:-Unit)', combine, ':-units');
 end try;

 # Turn `m`(radius) into just `m`, etc.
 res := subsindets(res,

 # Now that we've turned `m`(radius) into just `m` there may be more to do.
   combine(res, ':-units');
   subsindets(res, 'specfunc(Units:-Unit)', combine, ':-units');
 end try;
end proc:

A := x+180*Unit('km'*'deg')





theta := Units:-Standard:-`*`(90, Unit('deg'))


B := Units:-Standard:-`*`(Units:-Standard:-`*`(2, Unit('km')), theta)






R(Unit(Units:-Standard:-`*`('N', 'deg')))





Since it's often fun to have an alternate way...


eqn := -g*t-vs*ln(r*t-m0)+vs*ln(-m0);

                        eqn := -g t - vs ln(r t - m0) + vs ln(-m0)

pars := [r=13100,vs=2550,g=9.81,m0=2.8e6]:

cond := convert( t::solve( eval( r*t<m0, pars ) ), relation );

                        cond := And(-infinity <= t, t < 213.7404580)


                                     t < 213.7404580

new1 := evalc( eval(eqn,pars) ) assuming t<eval(m0/r,pars);

         new1 := -9.81 t - 2550 ln(0.28 10  - 13100 t) + 37855.08145 + 0. I

fsolve( new1=300, t=0..eval(m0/r,pars) );

                                     66.76469242 - 0. I



new2 := simplify(new1,zero);

                  new2 := -9.81 t - 2550 ln(0.28 10  - 13100 t) + 37855.08145

fsolve( new2=300, t=0..eval(m0/r,pars) );


fsolve( new2=300, t=-infinity..0 );


Try it like this, to protect aganst the situation that the unprotected names c or units have previously been assigned values.


That manner of coding applies to a variety of situations (including use of keyword option names, etc).

Note that those are single right-quotes, otherwise known as unevaluation quotes. Don't confuse them with single left-quotes, otherwise known as backticks or name-quotes.

The quotes protect against the situation that the name has been assigned. The colon-dash makes it use the global names, in case this call is made inside a procedure which happened to have the name in question also decalred as a local. There are lots of situations in which this handling is safest. But also note that Help page examples do not generally do it this way, even for names for which it may be applicable.


Here are some ideas for making a pair of animations run simultaneously (and close to "in sync") in a pair of Plot Components.

I inserted the two Plot Components from the side palette. The supporting play/stop code could be hidden inside Buttons. (If you wanted to get really fancy you could both construct and insert the whole assembly programmatically. That seems like overkill, for now.)

I suppose that the simultaneous play might appear more synchronized if the animation whose frames were slower to render were the one that was updated first, if using the frame-by-frame method. I'd expect a 3D surface to usually render slower than a simple 2D curve. YMMV.


There are two ways shown for doing progress bars in an example worksheet for Embedded Components that was new for Maple 2016. The Help Topic for that is examples,ProgrammaticContentGeneration 

If pressed I suspect I could make something similar work in Maple 14, but the background coding might look like shipbuilding with popsicle sticks.

I would guess that with that very many total iterations you naturally want to update the progress bar (only) modulo some large-ish number.


Attached is all I could see as recoverable from the file you posted (just an empty subsection...), by closing off the various open-ended XML tags.

The corrupted file seemed (to me) to end midway through an (encoded) inlined image.


1 2 3 4 5 6 7 Last Page 1 of 131