acer

32313 Reputation

29 Badges

19 years, 314 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Please put your additional details on this problem here, instead of in a separate Question thread.

@lcz The attached worksheet has code in its Startup Region which alters some GraphTheory routines. Hopefull it'll let you pass that stylesheet spec along to the interactive facility, as well as the earlier change to allow a Matrix/Table of interactive graph renderings.

I put it in a conditional to test for Maple 2021 or 2022, as I don't know whether the code edits are valid in other versions. It relies heavily on particular forms of the procedures (though I didn't put in a flag to prevent anyone accidentally rerunning the initial editing process twice).

GTinterstyle.mw

How large (typically) is Matrix A, and how fast do you need it to be?

Does Matrix A have special structure, eg. symmetric (real), etc?

Do you also need to optimize for doing this computation very many times for modest size?

@ijuptilk In versions 18 (and older) of Maple you would have to apply the evalf command to get arithmetic involving Pi and floats to produce a float result by default. Eg,

p[1] := evalf( 38.01/(Pi^2*(1-1.31/Pi)) );

Imagine the time that could be saved if you had bothered to inform us as to your specific old Maple version.

@ijuptilk When you submit a Question on Mapleprimes you should mark it with the specific version that you are using.

You can do that using the "Product" drop-menu, when editing/composing the Question.

If you don't bother to do that then we cannot tell whether you have a version that supports all the latest functionality.

If your version doesn't support the option maxsols = 200 for the Calculus1:-Roots command then see what happens when you omit it. It might still be adequate for your needs.

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

First 110 111 112 113 114 115 116 Last Page 112 of 591