mmcdara

3733 Reputation

17 Badges

6 years, 68 days

MaplePrimes Activity


These are questions asked by mmcdara

In Maple V the display of a lengthy expression often contained "auxiliary variables" named %1, %2, ... to make it more readable ( (a personal point of view, see for instance Introduction to Maple, A. Heck, p 97).
When did this feature disappear? Has it been replaced by something else?

TIA

 

When I have an operation to perform with Maple, my first reflex is to use the "native" Maple procedure(s) because it seems logical to think that they have been written in order to reduce the memory used and/or the execution time.
Unfortunately, this feeling is not confirmed by reading some of the answers provided on this site.

The attached file shows 4 ways (among probably several others) to center and reduce (by columns) a random matrix.
Amid them is the Statistics:-Scale procedure which appears not to be the most efficient (even a double loop outperforms in term of time).
This is just an example among many others (for instance Statistics:-Select can be easily outperformed)

So my question: why deceive the user with magic functions which sometimes have a very relative efficiency?

Scaling_efficiency.mw

I've finally decided to see what I could to do with DocumentTools.
I started with these simple lines from ?DocumentTools:-Do 

restart:
with(DocumentTools):
Do(int(%expression, x=%from::integer..%to::integer));
Error, (in DocumentTools:-GetProperty) Attempted to retrieve property of unknown component expression.

These next ones return the expected plot but an alert window 

restart:
with(DocumentTools):
Do(%Plot1=plot(x^2, x=0..1));


However the Click and Drag icon is disabled in the plot toolbar and invisible in the plot menu.

The behaviour of these commands do not depend on whether they are written in a worksheet, a section or a code edit region.

Could you detail me the very first steps do use DocumentTools features?

TIA

DT-Do.mw

I want to simulate the behaviour of a mass-spring system under an oscillating acceleration, but I also want that the mass remains between two rigid walls (no bouncing has to be considered).
Here is the notional example I use in the attached file (here x(t) will have to verify x(t) >= 0 and x(t) < 2).

s := t -> 10*cos(t)-x(t):

sys := { 
  diff(v(t), t)=s(t), 
  diff(x(t), t)=v(t), 
  v(0)=0, 
  x(0)=0
}:

When the mass reaches one wall it gets stucked at it until the acceleration allows it to take off from this wall. It can then move to the opposite wall and possibly get stucked at it waiting for appropriate conditions to fly again.
Here are two images to help you understand what happens:

  1. the first one represents the "unbounded" solution of the system above
  2. the second is the "bounded" solution
     

To obtain the right picture I construct the solution piecewise (the method, based on events and the use of discrete variables, is described in the attached file).
For some reasons I would like to build the global solution "in one shot" and no longer have to assemble it from elementary pieces (the blue, red and gray chunks on the right figure).
I've tried to do this through events but  I have failed so far (an ettempt is presented in the attached file).

From_wall_to_wall.mw

Could you show me how to use "events" to handle this problem?

Thanks in advance


I can't understand how to use Optimization in Operator Form when the objective function relies upon the numerical solution of a parameterized ODE.

Here is a very simple example :

  • I have a differential system that can be solved only numerically (so do not focus on the system I give to reply that I could solve it formally, I know that and the example is notional)
  • This system contains free parameters (K and M in my example) and an event whose firing time T I want to capture. 
  • The goal is to find what is the maximum value of T when K and M both belong to bounded ranges.
     
  • In the example I implicitely assumed that the event is fired for any (K, M) in their admissible ranges: this is a quite restrictive assumption that I will manage later.
restart:
sys := { M*diff(x(t), t$2)=t-K*x(t), x(0)=0, D(x)(0)=0};
evs := [[x(t)-5, halt]];

sol := dsolve(sys, numeric, events=evs, parameters=[K, M]):
interface(warnlevel=0):

TV := proc(P)
  sol(parameters=P):
  sol(10):
  return sol(eventfired=[1])[];
end proc:

# verification
TV([1$2])
                   HFloat(4.152620782382694)

# what I'm interested in
ranges := P[1]=0.8..1.2, P[2]=0.8..1.2:
Optimization:-NLPSolve(TV, ranges);
Error, (in Optimization:-NLPSolve) unexpected parameters: P[1] = .8 .. 1.2, P[2] = .8 .. 1.2

# another way
cstr := {0.8 < P[1], 1.2 > P[1], 0.8 < P[2], 1.2 > P[2]}:
Optimization:-Maximize(TV, cstr);
Error, (in Optimization:-NLPSolve) constraints must be specified as a set or list of  procedures


optim_parametric_dsolve.mw


I'm using both Maple 2015 and Maple 2020 and would appreciate an answer which fits these two versions.
Could you help me solve this issue?

TIA

First 6 7 8 9 10 11 12 Last Page 8 of 33