acer

32642 Reputation

29 Badges

20 years, 56 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Carl Love I don't know why it was done that way. Perhaps the author really preferred consistency, or half-expected that some other module locals might be needed later.

There are other appliable module exports of Student:-Calculus1 which are documented/user-level commands of the package. Some have other locals, and some do not. Eg,

op(eval(Student:-Calculus1:-InversePlot));

module () local ModuleApply; end module, ModuleApply

op(eval(Student:-Calculus1:-AntiderivativePlot));

module () local ModuleApply; end module, ModuleApply

op(eval(Student:-Calculus1:-DerivativePlot));

module () local ModuleApply, GetDerivativeOptions; end module, ModuleApply, GetDerivativeOptions

op(eval(Student:-Calculus1:-FunctionPlot));

module () local ModuleApply, NextAft, FunctionChartInfo; end module, ModuleApply, NextAft, FunctionChartInfo


Download SC1_am.mw

The OP has also asked me how I knew that it was such an appliable module, ie. a module with member ModuleApply, which (like a procedure) could be called with arguments.

One answer is simply that having such a module member ModuleApply is the mechanism that allows for that behaviour of a module's being callable like a procedure (ie. which could be applied to arguments).

But I also already knew it because I've worked with that command before.


ps. The printing mechanisms for modules have had a few quirks, over time, as the following shows:

restart;

kernelopts(version);

`Maple 2024.2, X86 64 LINUX, Oct 29 2024, Build ID 1872373`

op(eval(Student:-Calculus1:-InversePlot));

module () local ModuleApply; end module, ModuleApply

convert(eval(Student:-Calculus1:-InversePlot),string);

"module () local ModuleApply; end module"

op(3,eval(Student:-Calculus1:-InversePlot))

InversePlot:-ModuleApply

# same command as earlier!
convert(eval(Student:-Calculus1:-InversePlot),string);

"module () local ModuleApply; ModuleApply := proc (expr::algebraic, myrng::{range, And(name,Not(constant)), And(name,Not(constant)) = range} := NULL, {caption::anything := NULL, functionoptions::list := [], inverseoptions::list := [], lineoptions::list := [], showfunction::truefalse := true, showinverse::truefalse := true, showline::truefalse := true, title::anything := NULL, view::plotview := NULL}) local var, rng, a, b, Options, Function, Inverse, Line, CaptionFunction, mytitle, mycaption, myview, comma, usePiTicks, p, defview, d, i, j; option lock; Options := table([_options]); if myrng <> NULL then Options[1] := myrng; end if; try var, rng := ProcessVisual(expr,Options,{'range'},'true','true',plottools:-getdata(plot(expr,GetVariable(expr),'adaptive' = true),'rangesonly')[1]); catch: error; end try; myview := view; mycaption := caption; mytitle := title; if not type([_rest],'list'('PLOToptions'('`global`'))) then error "unexpected option(s): %0", op(remove('type',[_rest],'PLOToptions'('`global`'))); end if; try GetVariable(expr); catch: error; end try; p := plot(expr,`if`(myrng = NULL or type(myrng,'name'),NULL,var = rng),'adaptive' = true); if 0 < nops(select(type,[op(p)],AXESTICKS('identical'(_PITICKS),'identical'(DEFAULT),'anything'))) then usePiTicks := true; else usePiTicks := false; end if; a, b := op(rng); CaptionFunction := SelectTypesetName(var,'f','F'); if showfunction then Function := plot(expr,var = a .. b,'discont' = 'true','adaptive' = true,'legend' = CaptionFunction(var),'color' = Student:-Colours[1],op(functionoptions)); else Function := NULL; end if; defview := NULL; if myview = NULL then defview := indets(Function,'specfunc'('VIEW')); if nops(defview) <> 1 or op([1, 2],defview) = 'DEFAULT' then d := plottools:-getdata(p); defview := [seq(seq(map2(op,[2, i, j],[d]),j = 1 .. 2),i = 1 .. 2)]; defview := zip((a, b) -> a(op(b)),[min, max, min, max],defview); if type(defview,'list'('numeric')) then defview := min(defview[1],defview[3]) .. max(defview[2],defview[4]); defview := [defview, defview]; end if; else defview := defview[1]; defview := min(op([1, 1],defview),op([2, 1],defview)) .. max(op([1, 2],defview),op([2, 2],defview)); defview := [defview, defview]; end if; end if; if showinverse then Inverse := plottools:-transform((x, y) -> [y, x])(plot(expr,var = a .. b,'discont' = 'true','adaptive' = true,'legend' = 'typeset'(`_MessageCatalogue/GetMessage`("%1 reflected across %2","Maplets"),CaptionFunction(var),'y' = 'x'),'color' = Student:-Colours[2],op(inverseoptions))); else Inverse := NULL; end if; if showline then Line := plot(var,var = `if`(defview = NULL,a .. b,defview[1]),'color' = Student:-Colours[3],'linestyle' = 'DASH','adaptive' = true,op(lineoptions)); else Line := NULL; end if; if mytitle = NULL then mytitle := 'typeset'(`_MessageCatalogue/GetMessage`("Reflection across %1","Maplets"),'y' = 'x'); end if; if mycaption = NULL then mycaption := ""; comma := ""; if showfunction then mycaption := cat(mycaption,`_MessageCatalogue/GetMessage`("A graph of %1.","Maplets")); comma := " "; end if; if showinverse then mycaption := cat(mycaption,comma,`_MessageCatalogue/GetMessage`("The line %2.","Maplets")); comma := " "; end if; if showline then mycaption := cat(mycaption,comma,`_MessageCatalogue/GetMessage`("The reflection of %3 across the line %4.","Maplets")); end if; mycaption := 'typeset'(mycaption,CaptionFunction(var) = expr,'y' = 'x',CaptionFunction(var),'y' = 'x'); end if; if myview <> NULL then SetMessage(sprintf("Using view %a",myview)); end if; AddLegends(plots:-display(Function,Inverse,Line,`if`(title = "",NULL,':-title' = mytitle),`if`(caption = "",NULL,':-caption' = mycaption),`if`(myview = NULL,`if`(defview = NULL,NULL,':-view' = defview),':-view' = myview),`if`(usePiTicks,op([':-axis'[1] = ['tickmarks' = 'piticks'], ':-axis'[2] = ['tickmarks' = 'piticks']]),NULL),':-scaling' = 'constrained',_rest)); end proc; end module"

Download module_hmm.mw

@aroche Thanks, Austin!

I guess I was so hung up on avoiding the OP's earlier use of x>=0 that I was willing to accept R::real, unjustified, like a mirage. Thanks for the correction.

@dharr It seems to me that the OP's sentence,

  "Then,  `-\\infty` to `- + \\infty`."

pertains to the results that attain -- undesirably -- when he executes his original attempt.

And then he mentioned what he wanted,

   "How can I replace \infty with +\infty but keep -\infty unchanged?"

@dharr The temporary shunting aside is indeed a classic trick.

But perhaps you intended just,

    s2 := SubstituteAll(%, "#@#","-\\infty");

Here is a link to the explicit documentation: the Required Positional Parameters section of the parameter_classes Help page.

In particular, note this sentence from the first bullet point: "Note that the argument may be omitted if the flow of execution through the procedure is such that the parameter is never referenced."

And so a relevant error exception (with the prefix "invalid input") would get raised only if the procedure referenced more of such parameters as were passed validly as arguments in the call. See my example above.

This is long-standing behavior of procedure calling in Maple: that error is only raised for passing fewer such parameters than are referenced in the procedure. Here is the wording of that section's first bullet point in Maple 16.02 (released, 2012):

"A required parameter is one for which an argument must have been passed if the parameter is used during the execution of the procedure. In other words, a failure to pass an argument for a required parameter only raises an exception if an attempt is made to use that parameter during the particular invocation of the procedure."

An example that illustrates this concept, and explanation, is also given in subsection, "Required Parameters" of subsection "Referring to Parameters within the Procedure Body" of section 6.5 "The Procedure Body" of the current Programming Guide.

Please don't post a wholly separate Question which duplicates this topic. Not yet understanding fully this behavior or its consequences is not a decent rationale for posting Duplicate threads on this same topic. Duplicate Question threads get flagged as such and may be deleted. [I just deleted one such: 02/11/25] Instead, if you need this explained in yet more detail then add a followup as a Reply in this Question thread.

Also, don't put a great deal of stock in AI-generated responses (eg. such that some browsers of google queries provide); some such responses are quite inaccurate, and some are outright wrong.

[edit] Here is that subsection of section 6.5 of the Programming Guide (2024):

Required Parameters

 

Recall that a required parameter is one for which a corresponding argument must have been passed if the parameter is used during the execution of the procedure. Failure to pass an argument for a required parameter only raises an exception if an attempt is made to use that parameter during the particular invocation of the procedure.

For example, a procedure may determine, based on the value of its first required parameter, that it does not have to refer to the second required parameter.

Require := proc( x::integer, y::integer )
    if x < 0 then x^2 else x * y end if
end proc:

Require(-3);

9

Require(3,4);

12

Require(3);

Error, invalid input: Require uses a 2nd argument, y (of type integer), which is missing

@Hullzie16 Sorry to be a pain, but are you saying that, in a TTY shell on your MacOS, there is no Maple directory under  ~/Library/Preferences/  ?

If not then I don't know where it might be on your MacOS. The Maple 2025.1 Help topic,
      ?worksheet,reference,preferencesfile
indicates that location path.

ps. I found one old item that hinted that the file itself might be "Maple Preferences" with a capital "P".  But if you have no "Maple" subdirectory under ~/Library/Preferences/ then I don't know..., sorry.

@C_R On reflection, I appear to have been inaccurate in my consideration of case "number 2" above. Where I wrote,

   ... assuming R^2+(1-alpha^2)*x^2>0; # number 2

it does not follow that both R^2 and (1-alpha^2)*x^2 are both real. But where I wrote,

   ...assuming R^2>-(1-alpha^2)*x^2; # number 1

it does seem fair to take both sides of the inequality as real.

And indeed one can attain this:

simplify(expr) assuming ((1-alpha^2)*x^2)::real, R^2+(1-alpha^2)*x^2>0;

(-alpha^2*x^2+R^2+x^2)^(3/2)/abs(R)^2


But the system didn't deduce from both,
   ((1-alpha^2)*x^2)::real
    R^2+(1-alpha^2)*x^2>0

that R^2 must also be real, and then allow abs(R)^2 to become R^2.

So that seems like a weakness to me.

@Anthrazit I'm sorry, but I don't understand what you mean by, "...with all necessary code on the other side without the referenced files."

What is "the other side"?

How are files referenced? By $include directives?

How can files be referenced without being anywhere?

You haven't explained in clear or explicit detail your requirements, use-case, or behavior goals.

It's unclear what aspects you think would need to be different for code that wouldn't be in a package or stored to Library archive.

You should provide a clear example of what you're hoping to accomplish, that is (if possible) simple, while still representative of your difficulties encountered.

@C_R 

It's just done as usual.

You can even copy&paste the italic D into 2D Input (and so deliberately not get the global D the differential operator).

restart;

local D := Typesetting:-mi("D",mathvariant="italic"):

expr := D + X;

Typesetting:-mi("D", mathvariant = "italic")+X

eval(expr, D=2);

2+X

D, :-D, :-D(sin);

D

D(sin)

Parse:-ConvertTo1D, "invalid input %1", (Typesetting:-mi("D", mathvariant = "italic"))(sin)

restart;

local D:

alias(Typesetting:-mi("D",mathvariant="italic") = D):

expr := D + X;

Typesetting:-mi("D", mathvariant = "italic")+X

eval(expr, D=2);

2+X

D, :-D, :-D(sin);

D

D(sin)

Parse:-ConvertTo1D, "invalid input %1", (Typesetting:-mi("D", mathvariant = "italic"))(sin)


Download D_fun.mw

@C_R For the purpose of 2D Output (results of execution) you might try assigning/aliasing that last form I gave, to your local D.

@rquirt I am not sure if/how MapleFlow supports array-plots.

But I'll mention that even Maple itself has problems with exporting array-plots to a single image file. So, there's some precedence with such functionality requiring special handling.

ps. In Maple you can actually combine an array of plots into just one "plot" beast (which can be exported, etc). That involves temporariy setting the plot-device and calling plots:-display and assigning the result but suppressing its printing. Unfortunately that kludge does not allow for custom gridlines or log mode on the axis.

Would you be ok with the,
   output=dualaxisplot
result from BodePlot?

What, if any, information or data or equations do you need to pass/receive?

1 2 3 4 5 6 7 Last Page 2 of 597