Carl Love

## 27229 Reputation

11 years, 346 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

## Why are old posts becoming active?...

MaplePrimes

Why have there been so many old Posts and Questions moving to the top of the Active Conversations stack the past two days, even though they have no new activity? This makes MaplePrimes very difficult to use! Please make it so that the Active Conversations stack is sorted by the actual time of the most-recent addition to the thread.

## Trapping the stop button...

Maple 18

This Question involves using dsolve(..., numeric) for an IVP specifed by a procedure. This is based on a Question asked earlier today. In this Question, I have no interest in how to solve this IVP or in why this solution technique fails. In the worksheet below, the odeplot command seems to get stuck in an infinite loop (I am not interested in why that happens), and I press the stop button (in the Standard GUI). Then, instead of the usual Warning, computation interupted message followed by a return to the command prompt, I get an informative message and the plot that has been computed so far. This seems like a very useful feature: to return the results computed so far after an interuption. Furthermore, those results are programmatically accessible. My Question is How is this done? How do you trap the stop button and return the results?

 restart: Sys:= proc(N,t,Y,YP) local eqs,yp2,yp4;      YP[1]:= Y[2];      YP[3]:= Y[4];      eqs:= [           yp2*Y[3]+yp4*Y[2]*sin(Y[1]^2)+cos(yp4*Y[3]) = sin(t),           Y[2]*yp4*sin(Y[1]*Y[3])+5*yp2*Y[4]*cos(Y[1]^2)+t^2*Y[1]*Y[3]^2 = exp(-Y[3]^2)      ];      YP[2],YP[4]:= op(subs(fsolve(eqs,{yp2=1,yp4=2}),[yp2,yp4])) end proc: res:= dsolve(      numeric, procedure= Sys, initial= Array([1,1,2,2]),      number= 4, procvars= [x1(t),diff(x1(t),t),x2(t),diff(x2(t),t)],      start= 0, maxfun= 0 ):   plots:-odeplot(res, [t,x1(t)], 0..0.27); #After 10 seconds or so, (I did)/(you should) hit the stop button. Warning, cannot evaluate the solution further right of .25109286, cannot downgrade delay storage for problems with delay derivative order > 1, try increasing delaypts #Note that the command's result is still programmatically accessible: P:= %;

## Effective use of ModuleDeconstruct for o...

There are no examples for ModuleDeconstruct either on its help page or in the Programming Guide. Of course, I can figure out its basic and primarily intended purpose: to render the module/object in a one-dimensional plaintext printed form, which would be useful for debugging. But I am most interested in this use described in the second sentence of this, the second paragraph of Description at ?ModuleDeconstruct [italics added]:

When the value returned by ModuleDeconstruct is printed, the output could be capable of being parsed to the original module. When used with an object, ModuleDeconstruct can return an unevaluated call to a constructor to achieve this.

That seems very powerful. Is there any example of it being used in Maple library code? in user code? Can anyone here come up with a practical use for this? A Google search turns up nothing.

## Two strange results with indets...

Can anyone tell me what is going on in the following worksheet?

 restart:   The following type  matches any second-or-higher-order derivative specified in D form with independent variables. You don't need to understand how this type works---which is, admittedly, convoluted---in order to understand the rest of this post. TypeTools:-AddType(      HODD,      {typefunc(            name,            typefunc(                 name,                 {'`@@`'(identical(D), posint),                  And(specindex(posint, D), satisfies(D-> nops([op(D)]) > 1))                 }            )       )      } );   Here's an expression which is simply a sum of various types of derivatives. Note that the first and last terms only differ in the dependent variable name. expr:=      D[1,2](u)(x,t) + diff(u(x,t), x, t) + diff(f(x),x\$2) +      diff(f(t),t) + (D@@3)(f)(x) + D(g)(x) + D[1,2](v)(x,t) ; I1:= indets(expr, HODD); The above result is as expected: Ds of order greater than 1 are selected; diffs are not. Now I try to extract the diffs also.   indets(expr, HODD &under (convert, D)); The above result is missing D[1,2](u)(x,t) even though it contains the syntactically identical term D[1,2](v)(x,t)! Running trace  on `type/&under` shows that it never gets called for that missing term! So, the problem is not in &under. A further test shows that if the missing term is put elsewhere in expr (after restart, of course) then the indets works okay.   The following result is even weirder. One would expect that for any types T1 and T2 and any expression expr, that indets(expr, {T1, T2}) would equal indets(expr, T1) union indets(expr, T2), right? One would expect that even if there were a bug with one of the individual indets calls, right? So, note that I1 above contains the first term of expr, yet ... indets(expr, {HODD, HODD &under (convert, D)}); I get the same results if put the type explicitly in the indets calls rather than using AddType. I get the same results in Maple 16 and 18. So, what's going on?

## How to convert a hardware float to softw...

How do I convert a hardware float to a software float? I have a procedure that is passed floats as arguments. They could be hardware or software floats. I need to set an attribute on these floats (with setattribute). Trying to use setattribute on a hardware float produces utterly bizarre results, although, strangely, not an error. But I'd be happy converting them to software floats and then setting the attribute. I tried (separately)

UseHardwareFloats:= false;

convert(x, float, 16);

SFloat(op(x));

And, FWIW, here's the procedure, although I doubt that it'll provide any more useful information than I've already given. Note that in this procedure I've redefined log to be the base-10 logarithm. (Not that that makes the slightest difference wrt my Question.)

LogView:= proc(viewspec::{range, identical(DEFAULT)}, Range::range)
local aV, bV, aP, bP, aL, bL;
(aP,bP):= op(map(x-> 10^x, Range)); # The actual range of the ORIGINAL plot structure
if viewspec = 'DEFAULT' then
setattribute(op(1,Range), aP) .. setattribute(op(2,Range), bP)
else
(aV,bV):= op(viewspec); #The user-specified view in the pre-log units
if bV <= 0 then error "upper view limit must be positive; received %1.", bV fi;
(aL,bL):= op(Range); #Actual range of the log plot structure
setattribute(`if`(aV >= aP, log(aV), aL - (aP-aV)/(min(bP,bV)-aP)*(log(min(bP,bV))-aL)), aV)

.. setattribute(`if`(bV <= bP, log(bV), bL + (bV-bP)/(bP-max(aP,aV))*(bL-log(max(aP,aV)))), bV)

end if
end proc;

In the specific use instance that I'm dealing with, the first parameter, viewspec, is DEFAULT, and the second, Range, is HFloat(-43.42...)..HFloat(43.42...).

I think the ideal solution would be to use parameter coercion to convert the arguments.

 4 5 6 7 8 9 Page 6 of 9
﻿