acer

32333 Reputation

29 Badges

19 years, 321 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Read the Help pages for the commands from the HelpTools package.

That ought to provide the functionality for you Create a new database file, Store a custom Help pages to it, and so on.

There are also some Templates for Help pages.

You might also be able to do some of the management from the Tools item on the main menubar.

Sometimes in the past I have found some of this kind of documentation to be out of date, as the utilities get revised but some older instructions stick around for a while. Your mileage may vary.

Basically, when you call select the result is the same operation or container that it is passed.

In the documentation quote you cited the key phrase is, "creates a new object of the same type". Sometimes it's tricky to document behaviour and keep clear which terms are technical and which are being used in a more general sense. Here, a strictly technical definition might well be confusing for most people.

For example, calling select on this product returns a product.

select(type, x*sin(a)*7*cos(y)*z, specfunc({sin,cos})):
lprint(%);
sin(a)*cos(y)

The empty product is 1. The empty sum is 0.

[edit] This behavior in Maple is due not merely to mathematical convention. Or, rather, the convention is not merely incidental. It allows the math to work out more usefully. It allows the programming to work out much more usefully.

`*`(NULL);                                                                        
                  1

`+`(NULL);                                                                        
                  0

If you want to test whether the selected operands of the `+` or `*` expressions are NULL then you could operate on a list of those operands. For example,

[op(3*C)];
                         [3, C]

select(has,[op(3*C)],x);
                           []

[op(3+C)];
                         [3, C]

select(has,[op(3+C)],x);
                           []

I don't understand why you are substituting eval(Sqr), since that procedure a version of Dist with all those anonymous procedures inside the actual procedure body. What benefit do you get from that?! Is it really worth it?

If you are concerned with the life cycle of your code then I think you should give serious consideration to keeping the source in plaintext files, not worksheets. You can still have a worksheet that builds the package and stores it to an .mla file, etc. (You could use the read command on the master source file, and $include directives if you want to store some procedures in separate source files.) Plaintext files will almost never be corrupted, can be maintained by revision control, and accessed without need for Maple itself.

For example, if the source for procedure Dist (or even its template) were stored separately from the Test module source then you could run your testing scheme on it, while also $include'ing it in the source/build of Test. But you wouldn't need the contrived construction of Test:-Dist as a subs on eval(DistWorkSheet).

Getting back to the use of eval(Sqr), is that just a toy example, or is it possibly relfecting some situation where you want Sqr to be inlined into the body of Test:-Dist?

Here I use depends which may be generally better than merely checking for the presence of C[1] (which could possibly occur only as the dummy variable of integration, etc, which conceivably might not matter here).

[edit] To be clear, I think that `has` is wrong for this. I see little justification in using the weak tool  just because corner cases are rare.

You should avoid replacing with just a global name. You might replace with a procedure local created just for that purpose. Or perhaps you could freeze the exp calls.

restart;

expr:=1/exp(z)*arcsinh(x*exp(C[1]))+x*C[1]*sin(exp(x))
      +3*exp(C[1]*y)*sqrt(sin(exp(3*C[1]))):

depends(subsindets(expr, specfunc(exp), freeze), C[1]);

                    true

Now, since this is subsindets (rather than evalindets) there should be less concern with inadvertant evaluation. You don't want to have to worry about situations where the x inside exp(x) was needed so as to avoid accidentally wiping out a C[1] that really did occur outside of any exp call. So you could be more cautious and do it something like so:

depends( subsindets(expr, specfunc(exp),
                    u->%__exp(op(indets(u,name) minus {C[1]}))),
         C[1] );

The subsindets command can be used to process and substitute for subexpressions of a particular type.

Eg,

   subsindets( expr, specfunc(anything, exp), ()->Z );

will replace all exp function calls with just the name Z.

The last argument can be a procedure that accepts the subterms in question as its own argument. So more generally you can process and adjust the target subterms' substitutions -- rather than merely replacing them.

In newer Maple versions the 2nd argument can be specfunc(exp) instead of specfunc(anything, exp) .

Note also that there is a very useful correspondence between the indets and the subsindets commands. Your earlier use of indets and select can be changed to utilize the target type more directly and economically (and robustly, IMO, since has is a bit of a crude hammer).

restart;                                                                          
expr:=1/exp(z)*arcsinh(x*exp(C[1]))
      +x*sin(exp(x))+3*exp(C[1]*y)*sqrt(sin(exp(3*h))):

# You now did this.
s:=select(x->has(x,exp),indets(expr)):
select(x->op(0,x)='exp',s);

      {exp(x), exp(z), exp(C[1]), exp(C[1] y), exp(3 h)}

# But those could be obtained directly with this.
indets(expr, specfunc(exp));

      {exp(x), exp(z), exp(C[1]), exp(C[1] y), exp(3 h)}

Are you trying to accomplish something similar to this? I am not sure whether I properly understand your integration syntax (z and z').

(I have little idea what is your scale, or accuracy requirements, because you didn't bother to say.)

HH := 5*log[10]((c/H_0)*Int(1/(A*(1+zp)^4+B*(1+z)^3+C)^(1/2)/10,
                            zp=0..z,
                            method=_d01ajc, epsilon=1e-5)):

plot(eval(HH,[A=2, B=3, C=4, H_0=1, c=299792458]), z=1e-7 .. 1.0,
     thickness=3, color=red, smartview=false);

int(convert(1/tanh(u),sincos),u);

                   ln(sinh(u))

[edit] Also, if you're ok with it...

res := int(1/tanh(u),u):

   ln(tanh(u))-1/2*ln(tanh(u)-1)-1/2*ln(tanh(u)+1)

simplify(combine(combine(res,symbolic),symbolic),symbolic):

                1/2*I*Pi + ln(sinh(u))

There is a new command in Maple 2020, called ListTools:-Slice, which can split a list into n parts.

If it's not fast enough then tell us the performance/timing you want.

Also related is the (older) command ListTools:-LengthSplit.

 

I am interpreting your question to mean that you don't want to see any float approximations of multiples of Pi, but only want to see the rational multiples like Pi/3, 0, Pi/6, etc.

Here are two ways, one with Explore and one as a conventional animation.

You can of course adjust what plots are included, slow it down with duplicate frames, etc. I figured that the key thing is how the parameter value gets rendered, as mentioned.

I have used a textplot rather than a caption or title for the parameter info, because I dislike even the smallest amount of jitter in the display (as 0*Pi=0 which renders shorter, and other special cases).

There is no way to have the running value of a controller (Slider, etc) be displayed other than as an integer or float, as it appears beside the controller. So I suppress the alpha controller altogether, leaving only the animating slider shown.

(The Explore components look nicer in the actual Maple GUI, but this site's backend doesn't render those so well.)

restart

a := 4; b := 5; x0 := -3; y0 := -4

P1 := plot([a*cos(t)+x0, b*sin(t)+y0, t = 0 .. 2*Pi], scaling = constrained, gridlines, thickness = 3, size = [400, 400])

F := proc (n, N) local p; p := convert(n/N, rational)*Pi; plots:-display(P1, plot([a*cos(t)*cos(p)-b*sin(t)*sin(p)+x0, a*cos(t)*sin(p)+b*sin(t)*cos(p)+y0, t = 0 .. 2*Pi], scaling = constrained, gridlines, thickness = 3, color = red), plots:-textplot([-4, -4.5, ':-alpha' = Typesetting:-Typeset(Typesetting:-EV(p))], align = {right}, color = blue, font = [Times, 16]), view = [-9 .. 3, -10 .. 1]) end proc

Explore(F(n, 12), parameters = [[n = 0 .. 12, shown = false, animate]], frames = 13)

 

 

 

 

 

 

 

 

plots:-animate(F, [n, 12], n = 0 .. 12, frames = 13, paraminfo = false)

NULL

ROTATIONConiquesEllipseAnimation_ac.mw

[edit] In case you want an easy way (at the expense of size) to slow down the conventional animation by duplicating frames:

   plots:-display(seq(F(i, 12)$4, i = 0 .. 12), insequence = true)

If you add the option explicit to that solve call then those implicit RootOfs (of 4th degree polynomials?) may be expressed as (large) explicit expressions involving radicals. (The image is blurry; I find it difficult to see it well.) I mean,

   solve({f1,f2,f3}, [x,y1,y2], explicit);

In both 1D Maple Notation and 2D Input, the code that looks like x(2+1) and x(sin(y)) are function calls. It doesn't matter whether x has been assign a procedure or not -- those both still denote function application.

An unevaluated function call is a perfectly sensible and proper expression in Maple, and can be used for symbolic computation. Your two examples are equally as valid as function calls as f(x) or f(2+1) or f(sin(y)) are, even when f has not been assigned.

If you want to express a multiplication then you have to use valid syntax in the language that denotes it. And the examples you gave denote function application and not multiplication in the Maple language.

Note that for your example (with floats for both mantissa and exponent) the infix call to `^` gets automatically simplified by the kernel (its evalutation cannot be delayed or prevented using uneval quotes, which in some ways is analogous to its "happening early").

In contrast, the prefix form for `^` does not get automatically simplified.

I posit that the infix form gets automatically simplified (and computed at the current working precision) before the working precision gets set in the scope of the indexed call to evalf[n],

restart;
Digits := 10;
                          Digits := 10

# automatically simplification
'3.0^(1.2)';
                          3.737192819

# no automatic simplification
'`^`(3.0,1.2)';
                          ^(3.0, 1.2)

evalf[30](3.0^(1.2));
                          3.737192819

evalf[30](`^`(3.0,1.2));
                3.73719281884655197790004100992

# The behavior isn't caused by evalf's remember tables.
evalf[30](3.0^(1.2));
                          3.737192819

And, with the working precision already set to 30, we get the following. (I used evalf[300] just to demonstrate the same effect in the higher working precision.)

restart;

Digits:=30;
                          Digits := 30

evalf[300](3.0^(1.2));
                3.73719281884655197790004100992

When I trace through the 2D Input case then it seems to me that the prefix form is being used, once the 2D Parser processes it. (I vaguely recall once or twice having found a few other quirks along these lines, due to similar parsing differences.)

Find one of the appropriate terminal Application on your ubuntu. There should be several. I used the application named Konsole .  (There should be others, with names like Terminal, Xterm, UXterm, etc.)

You can easily find may answers to this with a simple web search. See here, for example. Here, let me Google that for you.

So, open a Linux terminal session.

Next, figure out where you Maple is installed. You launch the command-line interface for Maple using the file  bin/maple  located under the Maple installation.

For example, suppose that your Maple 2020 is installed here:

    /usr/local/maple/maple2020

Of course, the particular location of the installation depends on what was chosen by the person who installed it. We cannot tell you what was chosen. If you installed personally then it might also be here,

   /home/lisa/maple2020

And if you installed it as Linux user "root" then it might be here,

   /opt/maple2020

And if it was installed by your Linux systems administrator then you might have to ask them where they installed it.

In that case you can start the command-line interface by issuing the command:

    /usr/local/maple/maple2020/bin/maple

You can see various options for the Maple command-line interface here (but you may not need any).

You could also look at the Command-line Maple section of the readme.txt file located in your Maple 2020 folder.

I will mention up front that -- since omega[rK] only appears in subterms when it is multiplied by sigma^2 -- you could instead make the simple and direct subs call:

    subs(omega[rK]=tt/sigma^2, Is_square);

You may have already realized that works, directly, for your example.

But you may also wonder why the algsubs attempt did not work, so let's discuss that.

As explained on the algsubs help page, negative powers have to be treated separately. So, the following double call ought to work.

   algsubs(1/(omega[rK]*sigma^2)=1/tt,
        algsubs(omega[rK]*sigma^2=tt, Is_square));

Unfortunately the outer call gets confused by the coincidental presence of sigma in the name L[sigma] in the Is_square expression, and it runs amok.

If you changed the name L[sigma] to L__sigma then that double call would succeed. But you shouldn't need to make such an arbitrary substitution, especially manually.

It is possible to work the double algsubs call more methodically, by replacing the problematic indexed name (actually, here, all names) temporarily. I use freeze for that, with a dummy function call twist to force it.

Is_square := M[dmax]*(sigma^2*omega[rK]^2 + omega[r]^2)
             *L[sigma]/(3*p*omega[r]*omega[rK]*L[mu]^2*sigma^2);

(1/3)*M[dmax]*(sigma^2*omega[rK]^2+omega[r]^2)*L[sigma]/(p*omega[r]*omega[rK]*L[mu]^2*sigma^2)

F := ee -> subsindets(ee,name,u->freeze(__K(u))):

new := eval(thaw(algsubs(F(omega[rK]*sigma^2)=tt,
                 algsubs(F(1/(omega[rK]*sigma^2)=1/tt),F(Is_square)))),
            __K=(u->u));

(1/3)*M[dmax]*L[sigma]*(tt*omega[rK]+omega[r]^2)/(p*omega[r]*L[mu]^2*tt)

Download algsubs_ex.mw

Issue this command, exactly, to see what the current working directory is in Maple:

   currentdir();

Don't pass it any arguments. (The argument should be a forlder name, only passed if you want to change it. It's wrong and invalid to try and pass it the name of a file.)

The result should show you where your data file is being saved.

 

First 118 119 120 121 122 123 124 Last Page 120 of 336