acer

32333 Reputation

29 Badges

19 years, 325 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Your example works smoothly for me using Maple 2022.2 (no initialization file, no extra libraries...).

@mmcdara By the time it gets the `minimize/solve` the problem's been reformulated in exact rationals. However some RootOf's with float-range specifiers can still be generated.

The code-flow is slightly different, but in M2022 it's running into this (fwiw):

allvalues({x = 1/3*RootOf(7*_Z^3-279*_Z^2+2943*_Z-5049,14.92337354 .. 14.92337355), y = 1/3*RootOf(7*_Z^3-279*_Z^2+2943*_Z-5049,14.92337354 .. 14.92337355)},implicit)
Error, (in RootOf/RootOf:-algnum_in_range) invalid input: RootOf/RootOf:-rootof_in_range expects its 1st argument, rt, to be of type 'RootOf'(polynom(rational,_Z),identical(index) = posint), but received RootOf(7*_Z^3-93*_Z^2+327*_Z-187)

The _EnvExplicit=true makes it take a different code-path.

@mmcdara The Question was marked as Maple 2022.

fwiw, one may also use "" the empty string, i.e., a pair of double-quotes.

(I consider it a very slight advantage to use here something which might not be assigned a value.)

@Ronan That's right. I did not suggest placing the "\n" inside capitalized Typeset call.

As I mentioned, the lowercase typeset serves to allow math and text together (without a new comma visibly appearing to separate them). It doesn't even do anything by itself, but plotting commands turns its unevaluated function calls into a slightly differently named plotting substructure that the plot renderers (without added commas or text quote marks).

The "\n" is simply an example of such a string. It just happens to only contain a newline character in this example. Some other example might be, say,

  typeset("The integral is,\n", int(f(x),x=a..b))

In contrast a call Typesetting:-Typeset is one way to turn a name or math expression into a form that renders the same but won't later evaluate to some value. There are other ways to do that, eg. using the documented InertForm:-Display, or the undocumented `tools/gensym` to produce a new local instance of a name.

The lowercase word `typeset` was not a great design choice. It bothers me more that (by itself) it offers no evaluation prevention, and that it's Help page doesn't explain all this.

@Ronan Could you perhaps get some extra vertical spacing using newline characters, ie. with something simple like,

  typeset("\n", gamma2)

or,

  typeset(gamma2, "\n")

(or both above and below), though I'm away from a machine and forget whether the quote marks might show.

@Andiguys Sorry, I don't have time to fix so many worksheets.

I notice that several of your mistakes keep cropping up, despite previous corrections.

I suggest that you strive to properly understand what's been shown so far, so that you can correct most of these problems yourself.

You have,

exact_solution := (t, x_i) -> 2*Pi*p*sum(etan(n)*exp(-n^2*Pi^2*p*t)*n*sin(n*Pi*x), n = 1 .. infinity)/(eta0 + sum(etan(n)*exp(-n^2*Pi^2*p*t)*cos(n*Pi*x), n = 1 .. infinity))

What does the `x` mean in that, inside sin(n*Pi*x) and cos(n*Pi*x) ?

Did you instead intend, say,
   sin(n*Pi*x_i) and cos(n*Pi*x_i)
?

@janhardo 

expr := 2*sin(beta)^2+4*cos(alpha+beta)*sin(alpha)*sin(beta)+cos(2*(alpha+beta));

2*sin(beta)^2+4*cos(alpha+beta)*sin(alpha)*sin(beta)+cos(2*alpha+2*beta)

combine(expr);

cos(2*alpha)

@Scot Gould There is special code inside plots:-display to merge an "array" of 2D plots into a single PLOT construct. It serves this special case of wanting to export a collection like this in a single image file. Having the plot device set to an external image driver flips this on.

In order to do this the individual 2D plots are all shifted, and their tickmarks faked as textplots at mapped locations.

However, that shifting manipulation also turns the float tickmark values into names, eg, `-1.0` etc. And that makes them render in italics. That is likely why there is confusion about which fonts are being used.

Here's one workaround, using the previous code, to get usual upright Roman tickmark values instead. You also use the usual font option, see attached.

Note that I use .png image format for the export (which I find often like more).

I've used String@parse here, to turn those names-of-floats back into string text, but there are also Typesetting (or more careful) alternatives to re-manipulate those tickmark values (in TEXT substructures...).

restart;

with(plots):

P := seq(plot(x^n, x=-1..1, color=ColorTools:-Color([1/n, 1-1/n, 0]),
              size=[800, 400]), n=1..4):

Q1 := display(P[1], P[3]):
Q2 := display(P[2], P[4]):

here := cat(kernelopts(homedir), "/mapleprimes/example.png"):

plotsetup(png, plotoutput = here):
   G := display(< Q1 | Q2 >):
   #G := display(< Q1 | Q2 >, font=[Times,16]):
   subsindets(G,And(name,satisfies(u->parse(u)::numeric)),String@parse);
plotsetup(default);

restart;

here := cat(kernelopts(homedir), "/mapleprimes/example.png"):

img := ImageTools:-Read(here):
ImageTools:-Embed(img);

 

 

Download disp_ac.mw

ps. If you execute,
   display(G,axes=box);
after resetting the device with plotsetup(default) then you can see how the single PLOT is faked.

The server indicates that your first attachment is not accessible for download. I suspect that it's the filename. Could you reattach the first file, but using a different filename with no special characters like "+"?

Does it still go awry if you don't augment libname?

I can run it (with the libname change commented out).

note: the final plot uses `x` like a name, but at that point `x` is assigned a float value.

Are you trying to re-execute commands in the sheet out-of-order? If so we'd need to know the particular steps (presuming the issue is not due to something in your libname change...).

@Carl Love Yes, I more often think of it in terms of output effect in examples like for Factor.

It wouldn't normally occur to me to use it as an alternate terse input for a call that I'd expect to evaluate to something else -- as in the example given in this Question. I don't know whether the OP intends on using it in connection to generation of unevaluated function calls to aliased names.

@Carl Love I usually do the first of your alternatives, like,

    export XX:= Sqr1;

in order to get alternate spelling effects.

But then, I don't understand why anyone ever uses alias. It's like people playing the French Defense; I see how it works but I can't imagine ever wanting it.

@Ronan Notice that the calls to alias in your example above are not part of the body of any procedure (local or export). Those calls are just made as statement during the creation of the module.

Perhaps you can try having those statements instead be part of a ModuleLoad (local proc) of your other, problematic module(s).

I mean a ModuleLoad proc for the module, which might contain, say,

    alias(eparm, UHG:-CircleParmUHG);

You can have separate ModuleLoad procs for both parent module and submodules. See example at end. Or if you prefer you can put all your aliases in just a single ModuleLoad of the parent module. It depends on the effects you want.

If you access/reference/load any child module then the ModuleLoad of its parents (or parents' parents, etc) would also execute, IRC.

ps. Note that ModuleLoad of a module only gets automatically executed when it gets read in from a Library archive. Some people are in the habit of having a call to its own ModuleLoad be a final statement in a module's source code, so that they can test it immediately and directly without going to the trouble of LibraryTools:-Save, restart, etc. Or you can do the One True Test of an actual Save, restart, etc. That is to say, they don't have the statements in question appear standalone in the module source as well as be in the ModuleLoad proc. Just have them exist in one place, to manage them better.

pps. When I say "read" from a Library archive that's what I mean. It does suffice to call with on its name to read it in. But even without a call to with, any reference to the module name (eg. calling an export via longform name M:-foo ) would also read/load it from archive and trigger the ModuleLoad. This is off on a tangent.

restart

pkg:=module() option package; export Sqr, UHG; local ModuleLoad;
Sqr:=proc(x)
   return x^2;
end proc;
UHG:=module() option package; export CircleParmUHG; local ModuleLoad;
  CircleParmUHG := proc(T::algebraic, U::algebraic)
    local t, u, P, cp;
    t := T*denom(T)*denom(U);
    u := U*denom(T)*denom(U);
    if t::numeric and u::numeric and t<>0 and u<>0 then
      cp:=  <u^2 - t^2| 2*u*t| u^2 + t^2>/gcd(gcd(u^2 - t^2, 2*u*t), u^2 + t^2);
    else
      cp:=  <u^2 - t^2| 2*u*t| u^2 + t^2>;
    end if;
      return cp
    end proc;
  ModuleLoad := proc()
    alias(eparm=CircleParmUHG);
  end proc:
  ModuleLoad();
end module;
ModuleLoad := proc()
  alias(XX=Sqr);
end proc:
ModuleLoad();
end module:

XX(4)

16

eparm(2,7)

Vector[row](3, {(1) = 45, (2) = 28, (3) = 53})

LibraryTools:-Save(pkg,cat(kernelopts(homedir),"/mapleprimes/Ronin.mla"));

restart;

libname := cat(kernelopts(homedir),"/mapleprimes/Ronin.mla"),libname:

with(pkg);

[Sqr, UHG]

XX(4),eparm(2,7); # UHG is not yet loaded!

16, eparm(2, 7)

with(pkg:-UHG);

[CircleParmUHG]

XX(4),eparm(2,7);

16, Vector[row](3, {(1) = 45, (2) = 28, (3) = 53})

restart;

libname := cat(kernelopts(homedir),"/mapleprimes/Ronin.mla"),libname:

pkg:-Sqr(4);

16

eparm(2,7); # UHG is not yet loaded!

eparm(2, 7)

pkg:-UHG:-CircleParmUHG(1,3);

Vector[row](3, {(1) = 4, (2) = 3, (3) = 5})

eparm(2,7);

Vector[row](3, {(1) = 45, (2) = 28, (3) = 53})

 

 

Download 2024-06-29_use_alias_in_a_Sub_Package_ac3.mw

And, putting all the aliases in a single parent ModuleLoad,
2024-06-29_use_alias_in_a_Sub_Package_ac2.mw

First 33 34 35 36 37 38 39 Last Page 35 of 592