acer

32385 Reputation

29 Badges

19 years, 343 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

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.

 

No it is not a different s. It is the same s. That's the problem.

Is you don't need to subsequently substitute for the subscripts the you could use literal subscripts instead. Eg,

   omega__s1    and   omega__s

which prettyprint as subscripted names.

You called it a "user initialization file", ie. your own personal Maple initialization file, unrelated to the location where Linux is installed.

There is not one, by default.

Simply create/edit a file called .mapleinit in your Linux home directory, using your favorite Linux text editor.

It should contain Maple source code.

If you enter initialization into the search bar of Maple's Help system you could see that this is documented. See here, for the online page.

I am taking your description to mean that a can be any algebraic expression not depending on t, and that b can be any algebraic expression depending on t.

If you don't like depends you could change it to has. I don't know how you want to treat the cases where t is used as a dummy variable (of integration, etc).

I'm pretty sure that even if I've overlooked some corner case (or misinterpreted your definition) this could still be fixed up easily.

restart;

F := proc(ee::algebraic, nm::name)
       local s,o;
       if not ee::`*` then return false; end if;
       (s,o) := selectremove(depends,[op(ee)],nm);
       if nops(s)=0 or nops(o)=0 then false;
       else true; end if;
end proc:

F( (a+b)*(t^2+y), t );

true

F( (a+b)*(t^2+y)*t^5, t );

true

F( (t^2+y)*t^5, t );

false

F( (a+b)*c*(t^2+y)*t^5, t );

true

F( 3*t,t );

true

F( a*b*c, t );

false

F( a+b+c, t );

false

 

Download starchk.mw

It would be pretty straightforward to turn that into a type check instead. (I usually go for the easiest or first reasonable predicate I think of, instead of labouring over a slick structured type check that I may not immediately understand when I look at the code again in 3 years.) I don't know how exactly you intend on using it, whether performance is a key concern at huge scale, etc.

[edit] I don't recall seeing patmatch used robustly for a key role in a major project.

Here is another way, without hard-coded writing out of the trig/trigh terms' particular arguments.

You could also add the step to assign the _D names, but it wasn't clear to me that you wanted to.

restart;

sol := W(x) = _C1*(cosh(alpha*x) - sinh(alpha*x))
              + _C2*(cosh(alpha*x) + sinh(alpha*x))
              + _C3*sin(alpha*x) + _C4*cos(alpha*x):

L := [indets(sol,specfunc({sinh,cosh,sin,cos}))[]]:

temp := collect(sol,[sinh,cosh,sin,cos]):

CL := [coeffs(rhs(temp),L)]:

R:=[seq(cat(_D,i)=CL[i], i=1..nops(CL))];

[_D1 = _C1+_C2, _D2 = -_C1+_C2, _D3 = _C3, _D4 = _C4]

subs((rhs=lhs)~(R), temp);

W(x) = _D2*sinh(alpha*x)+_D1*cosh(alpha*x)+_D3*sin(alpha*x)+_D4*cos(alpha*x)

Download subsex.mw

If you don't need R for any other purpose then the last two of those statement could be combined together into this:

    subs(seq(CL[i]=cat(_D,i), i=1..nops(CL)), temp);

[edit] I'll point out that, as I see it, the order of the trig/trigh terms appearing in sol are rather arbitrary since in Maple those are can vary by session and the method of construction. Relying on that particular order of subterms in the sum seems like sloppy programming that might lead to later error, to me. Having said that, I don't see why one could not accept other terse variants such as the following (and it could be made shorter still).

   L := [indets(sol,specfunc({sinh,cosh,sin,cos}))[]]:
   temp := collect(sol,L):
   subs(seq(coeff(rhs(temp),L[i])=cat(_D,i), i=1..nops(L)),temp);

Of course, anyone is free to disagree with my rationale.

The authors of the package have stated steps here:
     https://www-polsys.lip6.fr/~jcf/FGb/FGb/x86_64_linux/index.html

Did you follow those steps?

(By the way, how do you think that relates to the version that is bundled in Maple 2020? Are you look for that site's specific version because of instructions for compatibility with another 3rd party package? It might help more if you described the full background of the query.)

The following can process 10^5 entries (sub-sets of set A) in about 1 second on my machine.

On my machine this was about 20% faster than mapping convert,string for 10^5 entries.

But for 100 entries I don't think that you'd be able to distinguish the difference.

restart;
A:={{"1","8"},{"1","4"},{"1","10"}};
           A := {{"1", "10"}, {"1", "4"}, {"1", "8"}}

map[2](sprintf,"%a",A);
          {"{"1", "10"}", "{"1", "4"}", "{"1", "8"}"}

An alternative but shorter syntax is,

sprintf~("%a",A);

You have made a common mistake in 2D Input syntax. Your two bracketed terms inside the sqrt are not being multiplied together. They are parsed together as a compound function call.

To get what you intended you can either insert an explicit multiplication sign or (in 2D Input mode) insert a space to denote mutiplication implicitly.

NULLassume(0 < k, k < 1)

int(x^2/sqrt((-x^2+1)*(-k^2*x^2+1)), x = 0 .. k)

EllipticF(k, k)/k^2-EllipticE(k, k)/k^2

``

Download ellipticIntegralTest_ac.mw

 

Could you make big_car itself an object, and pass that to the method procedure, etc?

[edited] I didn't really understand why you want big_car:-set_name declared as static, btw, given the rest of your example's structure and the original description you gave. But you could also change this code below so that big_car_name was instead declared as static(string).

restart;

module car_class()
      option object;
      local name::string :="UNKNOWN";

      export set_name::static:=proc(o::car_class,_name::string)
        o:-name := _name;
        o:-big_car:-set_name(o:-big_car,_name);
      end proc;

      #this is module, that I want to be private to this class only
      #eventually, I'd like this module be in separate mpl file also.
      local big_car::static :=module()  #module does not take arguments!
            option object;
            #this below should be private only to the this module
            #and not seen by the enclosing object.
            local big_car_name::string:="UNKNOWN";  

            #this export to allow parent object to call it
            export set_name::static:=proc(o::big_car,_name::string)
                   o:-big_car_name:=_name;
            end proc;

      end module;

end module:

o:=Object(car_class);

module car_class () local name::string; option object; end module

o:-set_name(o,"GM");

"GM"

# As desired, car_class does not export big_car .
#
o:-big_car:-set_name(o,"Ford");

Error, module `car_class` does not export `big_car`

 

Download object_submodule.mw

It's unclear what you mean by stating that you want big_car defined in its own .mpl file, if you want it declared as a (static) local of the car_class object. Do you just mean that the source of the car_class will $include the source of big_car?

Your first example contained the code snippet,
    big_car:-set_name("toyota")
which you claimed did set the name for your first variant. Is that incomplete and a typo, or actually what you meant? (I have guessed at the intended meaning to be that the car_class object would not export from submodule big_car literally/directly.)

One thing you should know is that the product 14*(7 - 2*sqrt(7)) will automatically simplify to 98-28*sqrt(7), and that cannot be prevented merely by delaying evaluation.

There are a few ways to represent that product so that it prettyprints nicely, and so that you can recover the actual value for further computation.

Here, I'll use the inert `&*` operator instead of the usual active `*`. By default that will prettyprint with a gray multiplication symbol. You can also use the InertForm:-Display command to make it prettyprint in the more usual way.

restart;

'14*(7 - 2*sqrt(7))';

98-28*sqrt(7)

ee := 98-28*sqrt(7);

98-28*7^(1/2)

new := `%*`(content(98-28*sqrt(7), sqrt(7)),
            primpart(98-28*sqrt(7), sqrt(7)));

`%*`(14, 7-2*7^(1/2))

value(new);

98-28*7^(1/2)

InertForm:-Display(new, inert=false);

0, "%1 is not a command in the %2 package", _Hold, Typesetting

 

Download auto_simp.mw

I will also mention that the alternative mechanism (to prevent actual multiplication) of using the ``(...) call will make the result prettyprint with round brackets even if that part is not a sum of terms.

You might also consider the following, though we do not know what other kinds of examples you might have.

content(98/3-28/3*sqrt(7), sqrt(7));
                               14
                               --
                               3 

icontent(98/3-28/3*sqrt(7));
                               14
                               --
                               3 

Also, if you are going to use these mechanisms programmatically then you might want to have a special case that primpart returns 1 or -1 (so that it doesn't print with unnecessary clutter). Again, we don't know what other kinds of examples you might have.

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