acer

32500 Reputation

29 Badges

20 years, 10 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@mmcdara Yes, they're quite different from each other.

That use of Typesetting:-Suppress affects how f(x) is pretty=printed in 2D Output in the Standard Java GUI (ie, typeset). But it doesn't relate to the plaintext input I type on my keyboard. It has the effect that the call f(x) is pretty-printed as just f, in 2D Output.

But alias(f=f(x)) does other things. For example,

restart;
alias(f=f(x));

                f

eval(f, x=3);

               f(3)

So that has changed what happens when I input the name f. And the way the call alias(f=f(x)) works can depend on some prior assignment.

@nm Having a shared engine (kernel) would be best illustrated by a value of some assigned name in one sheet affecting the same name in other sheet. The problem you describe with "restart" may (or may not) be due to the very same thing.

How is it functioning for you? Are you seeing the behaviour of distinct kernels (engines) across worksheets? Or are you seeing collision amongst assigned names and state, between worksheets?

@mnovaes The first argument passed to subs, ie. x=4 , is evaluated up front and becomes 3=4 even before the subs command receives it.

restart;

x := 3;

            3

trace(subs):

subs(x=4, 3);

 execute subs, args = 3 = 4, 3

            4

# Compare with, say,

subs('x'=4, 3);

 execute subs, args = x = 4, 3

            3

@mmcdara I suppose (hope?!) that this is all about interactive use, in which case alias is often useful and I don't object to it. If it works for you, then that's great.

I tend to look at things in a more programmatic perspective, in which I prefer not to assign to names which I still want to use as if they were unassigned. I suppose my preference is for approaches that work reasonably in both interactive and programmatic scenarios, where "reasonably" often has a connotation of scaling efficiently (as well as being straightforward to program).

@biol Do you mean something like this?

Or do you want to proceed the other way (formulaically), starting with an odd number and computing an even square that might be subtracted?

If it's homework/assignment/coursework, then how much of this do you think your ought to figure out yourself?

restart;

interface(typesetting=extended):

seq( seq( print( (2*j+1 + (2*n)^2 = (2*j+1 %+ (2*n)^2))
                 = 2*j+1 %+ (2*n)%^2 ),
          j=0..4*n+1),
     n=1..3);

(5 = `%+`(1, 4)) = `%+`(1, `%^`(2, 2))

(7 = `%+`(3, 4)) = `%+`(3, `%^`(2, 2))

(9 = `%+`(5, 4)) = `%+`(5, `%^`(2, 2))

(11 = `%+`(7, 4)) = `%+`(7, `%^`(2, 2))

(13 = `%+`(9, 4)) = `%+`(9, `%^`(2, 2))

(15 = `%+`(11, 4)) = `%+`(11, `%^`(2, 2))

(17 = `%+`(1, 16)) = `%+`(1, `%^`(4, 2))

(19 = `%+`(3, 16)) = `%+`(3, `%^`(4, 2))

(21 = `%+`(5, 16)) = `%+`(5, `%^`(4, 2))

(23 = `%+`(7, 16)) = `%+`(7, `%^`(4, 2))

(25 = `%+`(9, 16)) = `%+`(9, `%^`(4, 2))

(27 = `%+`(11, 16)) = `%+`(11, `%^`(4, 2))

(29 = `%+`(13, 16)) = `%+`(13, `%^`(4, 2))

(31 = `%+`(15, 16)) = `%+`(15, `%^`(4, 2))

(33 = `%+`(17, 16)) = `%+`(17, `%^`(4, 2))

(35 = `%+`(19, 16)) = `%+`(19, `%^`(4, 2))

(37 = `%+`(1, 36)) = `%+`(1, `%^`(6, 2))

(39 = `%+`(3, 36)) = `%+`(3, `%^`(6, 2))

(41 = `%+`(5, 36)) = `%+`(5, `%^`(6, 2))

(43 = `%+`(7, 36)) = `%+`(7, `%^`(6, 2))

(45 = `%+`(9, 36)) = `%+`(9, `%^`(6, 2))

(47 = `%+`(11, 36)) = `%+`(11, `%^`(6, 2))

(49 = `%+`(13, 36)) = `%+`(13, `%^`(6, 2))

(51 = `%+`(15, 36)) = `%+`(15, `%^`(6, 2))

(53 = `%+`(17, 36)) = `%+`(17, `%^`(6, 2))

(55 = `%+`(19, 36)) = `%+`(19, `%^`(6, 2))

(57 = `%+`(21, 36)) = `%+`(21, `%^`(6, 2))

(59 = `%+`(23, 36)) = `%+`(23, `%^`(6, 2))

(61 = `%+`(25, 36)) = `%+`(25, `%^`(6, 2))

(63 = `%+`(27, 36)) = `%+`(27, `%^`(6, 2))

Download odd_stuff2.mw

@nm That last aspect you mention is due to typesetting=extended. That is a problem with the normal output, and unrelated to the userinfo messages.

On my Maple 2021.2 for Linux (by default, with no initialization) I get standard returned by interface(typesetting) and do not see that issue when redirecting the normal output to a text file. I understand that on Windows it is different.

So you try could including the command,

   interface(typesetting=standard):

You could even put that command right before your writeto call which redirects to a file. (Your could also put another call right after your latter writeto call, if you want to reinstate an earlier setting.)

If that still doesn't work the I'd be interested to know whether the following works (retaining every separate execution group verbatim):

restart;

interface(typesetting=extended):

unprotect(userinfo):
userinfo:=proc(lev::nonnegint,
               nms::{name,set(name)})
  local ee,L,snms;
  interface(typesetting=standard):
  if nms::name then snms:={nms}
  else snms:=nms; end if;
  if nargs<3 then return NULL; end if;
  L:=[args[`if`(args[3]=':-NoName',4,3)..-1]];
  if nops(L)=0 then return NULL; end if;
  if ormap(nm->assigned(infolevel[nm])
               and infolevel[nm]>lev,
           snms) then
    if args[3]<>':-NoName' then
      printf("%s",sprintf("%s: ",
                          debugopts(':-callstack')[5]));
    end if;
    printf("%s",convert(L[1],string));
    for ee in L[2..] do
      printf(" %s",convert(ee,string));
    end do;
    printf("\n");
  end if;
  NULL:
end proc:
protect(userinfo):

 

infolevel[:-dsolve]:=5:

# include this!
dsolve(diff(y(x),x)=cos(x),y(x)):

 

interface(typesetting=standard):
writeto("output_of_dsolve.txt");  #send all output to file
sol:=dsolve(diff(y(x),x)=sin(x),y(x));
close("output_of_dsolve.txt"):
writeto(terminal); #to send output back to terminal

 

Download userinfo_redef2.mw

@Johan159 This call is crazy:

assign(sol1);

@lcz Nice challenge. I've got the initial frame's rendering to respect the stylesheet option (passed through). Getting the updates (upon dragging) to respect that is a bit more challenging. Hopefully I'll find a little time on the weekend.

I could believe that having larger (padded) vertex labels might make it easier to "grab" them for dragging.

Maple 2021 --  March 10
Maple 2020 --  March 12
Maple 2019 --  March 14  (Pi day)
Maple 2018 --  March 21

@AHSAN Please put your close follow-up queries and details here, instead of spawning a separate Question thread.

Please put followup details for this query here, in Comments/Replies, instead of submitting a separate Question thread.

@John2020 Is this the kind of thing you're after? (If so then please test with nontrivial examples of your own. It's easy to overlook cases when coding.)

restart;

DGP:=proc(ff,var) local ee;
  ee:=combine(frontend(expand,[ff]),':-power');
  max(map(proc(u,v)
      if u::`*` then
        op(2,combine(select(type,u,
                            identical(v)^anything),
                     ':-power'));
      else
        if type(u,identical(v)^anything) then
          op(2,u);
        else return FAIL end if;
      end if;
    end proc,
    [`if`(ee::`+`,op(ee),ee)],var));
end proc:

 

H := a*x^k+b*c*x^(2*k):

DGP(H, x);

max(k, 2*k)

DGP(H, x) assuming k>0;

2*k

DGP(H, x) assuming k<0;

k

DGP(s^w-p*s^(-w/2)-z*s^(-w), s);

max(w, -w, -(1/2)*w)

DGP(s^w-p*s^(-w/2)-z*s^(-w), s) assuming w>0;

w

DGP(s^w-p*s^(-w/2), s) assuming w<0;

-(1/2)*w

DGP(s^w-p*s^(-w/2), s);

max(w, -(1/2)*w)

P := (s^w-r*s^(-w/2))*s^w;
combine(expand(P),power);

(s^w-r*s^(-(1/2)*w))*s^w

s^(2*w)-r*s^((1/2)*w)

DGP(P, s);

max(2*w, (1/2)*w)

DGP(P, s) assuming w>0;

2*w

DGP(P, s) assuming w<0;

(1/2)*w

Download para_deg.mw

Here is a simple revision of that AltDGI procedure, which handles Matrices as well as lists (of Graphs).

graph_interactive_table_acM.mw

@nm Ok, so you only need assertion-checking for the local-variable and return-value type checks of your own procedures. That's more detail.

In that case either of the ways I showed of temporarily disabling certain kinds of assertion-checking in your calls to Library code might help with the kind of example you've shown.

First 114 115 116 117 118 119 120 Last Page 116 of 595