acer

32587 Reputation

29 Badges

20 years, 35 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

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?

@nm That looks ok. I just pasted into the outer Not from elsewhere, where I was doing the entire thing in a structured type, and didn't simplify.

@sand15 In modern Maple the Explore command is just one particular facility based on Embedded Components programming. Using Embedded Components is an alternative (more full than is just Explore) to using Maplets here, and it too can get around issues with zoom, size, spacing under title, etc, for 3D plots.

@Rouben Rostamian  You wrote, "The hemisphere may be plotted more efficiently in spherical coordinates. Then there won't be a need to for an excessively fine grid."

Oh, I know, I know. I usually do it that way. But I'd only had one coffee and I could already see how I could easily exclude the cut-out portion of the hemisphere in cartesian coordinates, so I went for it and relied on the adaptmesh=true functionality. With the yellow lip, the inner edge is hidden. I may not have needed quite such a fine mesh, but under certain lighting any tiny wave in the lower edge circle due to adaptmesh=true gets revealed in shadows. That's why I up-voted janhardo's -- for doing it the way I know I ought to...

After I finished, I took a look at the worksheet that janhardo has uploaded in the interim.

I notice that his spacecurve and mine are done similarly, as well as a set-up to allow the cylinder placement/dimensions to be varied.

We did the cylinder and hemisphere differently, so that's fun.

I used a fine grid, to avoid a ragged edge where I "chopped" the cylinder after creation. I like janhardo's use of trig, as well as his use of variable/dependent plotting ranges. But is the base circle/edge of his hemisphere ragged?

@WD0HHU 

Here is an old Post (2012) on this site, in which I showed a base technique for rendering an arbitrarty image on a 3D plotted surface.

At some point in that discussion, people started showing planet images on spheres. For example. (One doesn't need to use one of the very huge sized images; there's a variety.)

The base technique in that Post is now superceded by the image option of plot3d. Eg,

im:=ImageTools:-Read("http://www.vendian.org/mncharity/dir3/planet_globes/TemporaryURL/mars0_src_smaller.jpg"):
plot3d(1, x=0..2*Pi, y=0..Pi, coords=spherical,
       style=surface, grid=[2*128,128], image=im);

So that provides simply a more direct way to do what ImageTools:-Preview does (except the latter forces a particular orientation). Naturally, one can also use plots:-display to add a new size.

And all the above is for 3D. It's also not what I've shown in my Answer, mostly because it's not a great way to handle the thorny matter of blurriness of written text in the image.

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