acer

32333 Reputation

29 Badges

19 years, 322 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Upload and attach the Document in which this occurs.

Posting an image of a Document is much less useful than posting the Document itself.

@mmcdara I am unable to download your attachment, possibly due to the choice of file name.

I have a few different and reasonably efficient ways to shade a 2D region (with a pretty smooth gradient).

But the OP did not explain what manner of shading he wanted. He mentioned a 1D domain, and I just happened to give three shadings of curves based on that domain, as well as one shaded 2D region. But we cannot as yet know what he wanted.

The problem occurs if the overloaded export procedure does not have a fallback procedure that lacks option overload.

LinearAlgebra:-Multiply and LinearAlgebra:-Add have such a procedure in their overload definition, and do not exhibit the problem.

LinearAlgebra:-CompanionMatrix and LinearAlgebra:-MatrixInverse lack such a procedure in their overload definition, and both exhibit the problem.

I haven't seen a non-overloaded procedure with the problem (so far).

Since the problem occurs even when there is a procedure that matches the argument type then I think that this is a kernel bug related to overload. If it's deemed necessary or desirable kernel behavior then I think that Library routines like MatrixInverse should be adjusted to accomodate it.

restart;

M:=module() option package;
  export e,f,g,h;
  e := overload([
         proc(x::positive) option overload; x^2; end proc,
         proc(x::negative) option overload; x; end proc ]);
  f := overload([
         proc(x::positive) option overload; x^2; end proc,
         proc(x::negative) x; end proc ]);
  g := overload([
         proc(x::positive) option overload; x^2; end proc ]);
  h := overload([
         proc(x::positive) option overload; x^2; end proc,
         proc(x::odd) option overload; x^3; end proc,
         proc(x::negative) x; end proc ]);
end module:

with(M):

proc() uses M; e(3); end proc();
proc() uses M; e(-3); end proc();

e(3)

e(-3)

proc() uses M; f(3); end proc();
proc() uses M; f(-3); end proc();

9

-3

proc() uses M; g(3); end proc();
proc() uses M; g(-3); end proc();

g(3)

g(-3)

proc() uses M; h(3); end proc();
proc() uses M; h(-3); end proc();
proc() uses M; h(-4); end proc();

9

-27

-4

 

Download overload_fun2.mw

Please don't post a duplicate of this for your specific textbook example. Put the example in this Question thread, instead.

You should either read the relevant documentation and Help pages, or provide us with the full details of your example.

What have you tried, so far?

@radaar If the Hessian has both positive and negative eigenvalues then the point is a saddle point.

If the Hessian's eigenvalues are all positive then the point is a local minimum. If the Hessian's eigenvalues are all negative then the point is a local maximum.

If the Hessian is positive-semidefinite or negative-semidefinite then the test is inconclusive.

@Adam Ledger You wrote, "...MTInterface has no arguments." That is incorrect terminology. What you may have intended to convey was that the procedure is defined with no parameters.

Lots of Maple procedures are defined with no parameters. And when they get called with arguments then those arguments can be accessed by the procedure in a few ways.

For example,

f := proc()
  print( nargs );
  print( seq( args[i], i=1..nargs) );
  print( _npassed );
  print( _passed );
end proc:

f( a, 4, b, 7.2 );

                       4
  
                  a, 4, b, 7.2

                       4

                  a, 4, b, 7.2

See the Help pages under Topic procedure for details.

The procedure about which you were asking used the _passed facility to reference the passed arguments.  See the line that contains procname(_passed) .

I think that you'll need to understand the basics before trying to understand advanced examples. Also, not every internal procedure is implemented in the Library in interpreted code.

@panke To address your dsolve followup question, look at my Answer's third example (as I suggested above).

restart

RMP := proc (sl, t1, A1, t2, tau) local y; if not type(tau, numeric) then return ('procname')(args) end if; if t1 < tau and tau <= t2 then y := A1 end if; return y end proc:

ode := diff(x(t), t) = RMP(2, 3, 3.7, 5, t);

diff(x(t), t) = RMP(2, 3, 3.7, 5, t)

sol := dsolve([ode, x(0) = 0], numeric, range = 0 .. 6, known = [RMP]):

plots:-odeplot(sol);

 

Download plotproc_dsolve_ac.mw

I assume that this is merely a simple example of the concept, and that you may have some additional example in which the known procedure is more involved (and careful in how it handles all possible cases). Otherwise you could have used another, simpler mechanism for the piecewise effect.

@panke You haven't explained how you wish to use it, in detail, so you leave it up to us to guess.

I am guessing that you want to use it like a known function, in a call to dsolve(...,numeric) and that you could try the last of the ways I showed. I mean the example where RPM2 returns 'procname'(args) if tau is not of type numeric. Of course you can rename the procedure, or not.

I assume that this is merely a simple example of the concept, and that you may have some additional example in which the known procedure is more involved (and careful in how it handles all possible cases). Otherwise you could have used another, simpler mechanism for the piecewise effect.

As usual, you have left out the important details of your question.

Is your interest in univariate of multivariate functions?

Are you looking for exact results, or numeric approximations?

Are you looking for all solutions, or just a finite number (eg, one)?

Do you have a candidate example that has some special difficulty?

@naili You are treating your F as if it were a procedure/operator, but you defined it as an expression in x and y but not as a procedure/operator.

This would work, defining F as an operator.

restart;
F := (x,y) -> (sin(sqrt(x^2+y^2)))/(sqrt(x^2+y^2));
h := F(x, -1.8);
ListeHy := [seq(h, x = -10..10, 1.0)]:
ListeHx := [seq(x, x = -10..10, 1)]:
HxHy := zip(`[]`,ListeHx,ListeHy);
polyInterHxHy := CurveFitting:-PolynomialInterpolation(HxHy, x):
plotHxHy := plot(polyInterHxHy, x = -10..10, size=[400,400]);

And this would also work, with F just as you had it, ie. an expression in x and y.

restart;
F := (sin(sqrt(x^2+y^2)))/(sqrt(x^2+y^2));
h := eval(F, [y=-1.8]);
ListeHy := [seq(h, x = -10..10, 1.0)]:
ListeHx := [seq(x, x = -10..10, 1)]:
HxHy := zip(`[]`,ListeHx,ListeHy);
polyInterHxHy := CurveFitting:-PolynomialInterpolation(HxHy, x):
plotHxHy := plot(polyInterHxHy, x = -10..10, size=[400,400]);

Notice that h is the same in both versions, and so is all that follows the definition of h. It's just the first two lines that are different. Run both, and look carefully at the input and the output of the first two lines.

An operator is just a special, simplie kind of procedure that prints and can be defind with an arrow.

@itsme One of the advantages of a Maple Library Archive file (.mla) is that its contents are immediately accessible in any fresh session in which the location is part of `libname`.

In contrast, using `read` on-the-fly involves more parsing/interpreting/processing overhead. For larger projects the difference in loading time can be significant. Ie, it can get very onerous, if a slow and involved reread & reprocess is required at each restart.

Also, the $include process is supported by an "include path" mechanism which allows for multiple location trees and easily specified paths (programmatically set within Maple, or specified as options to scripts or the commandline interface).

There are several implications from the above. Eg. source repositories can be flexibly shared by multiple developers at different sites, without hard coded absolute paths, etc.

So, there is nothing outright wrong with using `read` (even on-the-fly, per restart) as a quick setup for a small, simple project. But it's a "poor man's" development system, and not best for scaling up projects.

There are some big and complicated projects and packages out there (... we just don't see their development details discussed here).

@Earl There are several commands for producing field plots. Why not use one of them (which produce arrows, in a customizable manner), instead of contourplot?!

@janhardo None of that is grammatical English, and I'm sorry but I cannot understand what you are trying to say.

@janhardo I disagree that those commands are complicated.

Taking a list of numeric values L, and producing a list of lists [p,f(p)] for every p in L , is not complicated. In fact it is a quite straightforward and rather basic example of Maple programming.

There are other ways to do that subtask. None is best. Most are straightforward.

There are also slicker (and more obscure, IMO) ways to do that subtask. Most such simple tasks can be done in multiple ways. I have tried to do several of them in ways that are more easily understood. I advise you to choose ways you understand better over ways that are slicker and terser.

 

First 172 173 174 175 176 177 178 Last Page 174 of 591