acer

32480 Reputation

29 Badges

20 years, 6 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Your general question appears to be answered by Preben.

But you might be interested to know that nops() does not return the number of entries (size) of a Vector.

For V:=Vector(7),

> op(1,V);
                               7

> op(2,rtable_dims(V));
                               7

> LinearAlgebra:-Dimension(V);
                               7

> nops(V);
                               3

Having a single command which returns the number of entries for any of Vector, list, array, etc, has been suggested in the past. It would be useful, consistent, and less confusing. (But it cannot be nops, since that already has another purpose for Vector, rtable, etc.)

acer

Combine the two Answers given so far. One of them shows you how to change one file name to another, or how to programmatically generate filenames (or either flavour). The other tells you which command to use to rename an external file.

Use both together, to programmatically rename all the external files.

acer

You can set the prettyprint level to match the output of either the commandline or Classic interfaces. Eg,
interface(prettyprint=1):

acer

I have (32bit) Maple 11.02 installed on a Windows 7 Pro 64bit machine. And its Standard GUI opens and saves worksheets ok, for the few worksheets I tested. The saved worksheets re-open fine in, say, Maple 14.

I expect that you would certainly need to install the upgrade to 11.02 (since a fix for the file-save dialogue on Windows Vista was introduced in the 11.01 upgrade). See this link.

(This is under an account with admin priviledge, if that matters. I don't remember installing it in any "XP mode", but perhaps I've forgotten. Windows 7 asks me whether the Maple kernel should be allowed to communicate over the network, the first time I ran it. I allowed that, since I knew that Maple's kernel normally talks to its interfaces over the loopback network device. That happened for other, recent versions of Maple too, and isn't a big deal.)

acer

One can now use the read command from within the Standard GUI. And $include directives can be used within the .mpl text source file that gets read.

This is how I usually lay out the source of more involved modules, where each export or local (proc) gets $include'd from a master .mpl text source file. By using the `read` command on the parent .mpl file I can access the material from within both commandline and Standard graphical Maple interfaces.

And currentdir and kernelopts(includepath) can be set programmatically, to give the whole process even more polish.

I don't care for the new RunWorksheet command as it can break some of the very useful evaluation rules that actual procedures have. (See here, for a simple example of said benefits.) It's not conducive to writing procedures. And it's awkward to set up. And then there is debugging it...

One bit difference between using plaintext & read versus libname & .mla Library archives is that the former may need to do more work if the source file actually does some computation or processing work. If the source file sets up a really big module package, or does other pre-calculation, then one might not want that to be reproduced with every re-read of the source.

acer

I set up the 2008 version of MSVC++ on a 64bit Windows 7 Pro machine, and Maple 14's Standard GUI and its Compiler work for me. More importantly, enabling the Compiler did not break the Standard GUI for me.

I installed the Visual Studio components after installing Maple 14. And then I ran Compiler:-Setup.

I do see this file, after installing the Visual Studio components.

 C://Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/vcvars64.bat

First things first. Did you install (MVSC++ download of) the Visual Studio Express Edition (2008 version)?

Next, did you also install the Windows SDK for Windows Server 2008 and .NET Framework 3.5? My understanding is that the vcvars64.bat file is included in that SDK.

ps. I have heard a rumour that someone got the 2010 Visual Studio Express Edition to work, but only after (even more) fiddling (and possibly even writing by hand) to get that batch file. I haven't done it, at this date.

pps. Did you know that you can configure the Standard GUI to use Worksheets (not Documents) with 1D Maple Notation (not 2D Math input) by default in new sessions? That means you can get new features like polar axis plotting, 2D Math in plot captions, etc, etc, in inlined (not just Maplet) plots, while retaining quite a bit of the look & feel of the Classic GUI's "red prompt".

acer

You should be able to handle this in one of two ways. You can either test that the result is of a type (that a solution would take), or you can test whether the result is NULL or an unevaluated `fsolve` call.

result := fsolve(...);

if result = NULL or type(result, 'specfunc(anything,fsolve)' then
  no_solution_found := true;
end if;

# or, in the multivariate case,

if not type(result, set(symbol=complex(numeric))) then
  no_solution_found := true;
end if;

Notice that if you are choosing to test whether the result has a given form then the type-check may depend on how you called fsolve. These next two should illustrate that. Note also that you can choose to test whether the numeric result is purely real (ie. of type numeric which would be purely real instead of type complex(numeric) which might have nonzero imaginary part).

> result := fsolve( sin(5*x+3) , {x});
                      {x = 0.02831853072}

> type(result,set(symbol=numeric));
                              true

> result := fsolve( sin(5*x+3) , x);
                         0.02831853072

> type(result,numeric);
                              true

One can see, that it's a bit easier to check whether the `fsolve` attempt failed. If you had success, then how you pick apart the result will depend on how you called fsolve, and perhaps on how many variables were involved or whether the input was a univariate polynomial (in which case multiple solutions may be returned). How you test for that, or how you pick apart the solution, will thus depend on the problem at hand.

Now here is a related digression. You have realized that the result maybe a so-call unevaluated fsolve call, which is a fancy way of describing the situation that fsolve returns something that looks like the original call -- ie. a function call to `fsolve` itself.

If you test this at the top-level, outside of a procedure, then Maple will try once again to evaluate that function call when you inspect it by passing it on to your test. You likely don't want that, since you don't want your code to waste time duplicating a non-fruitful computation.

But if you instead perform the original fsolve call and the subsequent check inside a procedure, where result is a declared local variable, then any unevaluated fsolve function call will not get re-evaluated when your pass it around for the test.

Let's verify that claim, by simply counting how many times the argument to fsolve itself gets called. We'll use a procedure `f` as the thing to be solved-for, but the overall effect is the same even if the thing to be solved-for is an expression.

> restart:

> f:=proc(x)
>   global count;
>   count := count+1;
>   sin(5*x+3)-4;
> end proc:

# First let's do it inside a procedure.
 
> p:=proc(F) > global count; > local result; > result := fsolve(F); > printf("total number of f calls done: %a", count); > if type(result,numeric) then > print("root found"); > else > print("no root found"); > end if; > printf("total number of f calls done: %a", count); > end proc: > count := 0: > p(f); total number of f calls done: 828 "no root found" total number of f calls done: 828

Notice how the total number of calls to `f` did not increase due to calling `type` against the result

# Now, let's do it at the top-level, outiside if any procedure.

> count := 0: > result := fsolve(f); result := fsolve(f) > printf("total number of f calls done: %a", count); total number of f calls done: 828 > if type(result,numeric) then > print("root found"); > else > print("no root found"); > end if; "no root found" > printf("total number of f calls done: %a", count); total number of f calls done: 1656

Look what's happened. The total count of calls to `f` has doubled, following the `type` check!

The very act of passing the unevaluated fsolve call (assigned to `result`) to `type`() at the top-level causes it to get re-evaluated and thereby duplicates the entire unproductive attempt. But inside the procedure `p`, the variable `result` is a local variable and as such gets only one-level evaluation when passed into `type`(), and so does not cause a re-computation attempt.

When done at the top-level, in the case that the computation failed and returned unevaluated, the mere act of checking it causes the failing computation to be needlessly redone. This can be quite an important distinction when one is concerned with efficiency or when the computation takes a very long time. The very same issue would arise when calling `int` to do symbolic integrals and then passing around an unevaluated `int` call, except that `int` may be safe from this effect due to its having remember tables to store prior results. But the issue can arise elsewhere, since not all Library routines which can return unevaluated have remember tables.

This is one important reason why programming in Maple (ie. writing and using procedures) is important.

acer

Or you could try the top-level `copy` command.

acer

It looks like MTM:-subs doesn't really support multiple substitutions. This seems to be the case for both sequential substitutions (more that two arguments with all last denoting substitutions), or concurrent substitutions (first argument being a set).

If you want your `with` calls to be at the top then you can use the global form :-subs() in the code portion.

Or get rid of the with(MTM) if you don't need it, as was mentioned by Kamel.

In essence, MTM:-subs is designed to behave like the Matlab command subs and not like the Maple command `subs`. They were written for different products, and they behave differently. (It's not relevent that the Matlab `subs` command is part of it's old symbolic toolbox which used Maple once upon a time. The command was still designed for Matlab use and the Mathworks made it do what they wanted and had no cause to mimic Maple's `subs` command.)

acer

I'm not sure (yet) whether this is the full solution. I didn't have the patience to see whether solve({fff},AllSolutions) would ever return a result, as it took so long.

> solve(simplify(eval({fff},{x[22]=1,x[23]=0,x[31]=0,x[32]=1,y[21]=0})),AllSolutions);

                           /     1 \ 
                          { T = --- }
                           \    _Z1/ 

> about(_Z1);

Originally _Z1, renamed _Z1~:
  is assumed to be: integer

I got this by substituting new simple names for each of the sin & cos calls, solving, resubstituting, and trying to test whether the resubstitutions introduced inconsistency.

Oh, hang on! There is at least this larger set,

> SOL:=solve(eval({fff},[x[31]=0]),AllSolutions);

 /     1                                             \   
{ T = ---, x[22] = 1, x[23] = 0, x[32] = 1, y[21] = 0 }, 
 \    _Z1                                            /   

   /     1                                             \    /
  { T = ---, x[22] = 1, x[23] = 0, x[32] = 1, y[21] = 0 }, { 
   \    _Z2                                            /    \

          2 Pi                                                  
  T = -------------, x[22] = 1, x[23] = 0, x[32] = -1, y[21] = 0
      Pi + 2 Pi _Z3                                             

  \    /        2 Pi                                         
   }, { T = -------------, x[22] = 1, x[23] = 0, x[32] = -1, 
  /    \    Pi + 2 Pi _Z4                                    

           \    /         2 Pi                               
  y[21] = 0 },  |T = ---------------, x[22] = 0, x[23] = -1, 
           /   <     1                                       
                |    - Pi + 2 Pi _Z5                         
                \    2                                       

                      \    /         2 Pi                   
  x[32] = 1, y[21] = 0| ,  |T = ---------------, x[22] = 0, 
                       >  <     1                           
                      |    |    - Pi + 2 Pi _Z6             
                      /    \    2                           

                                  \    /          2 Pi         
  x[23] = -1, x[32] = 1, y[21] = 0| ,  |T = -----------------, 
                                   >  <       1                
                                  |    |    - - Pi + 2 Pi _Z7  
                                  /    \      2                

                                             \    /
  x[22] = 0, x[23] = 1, x[32] = -1, y[21] = 0| ,  |
                                              >  < 
                                             |    |
                                             /    \

            2 Pi                                           
  T = -----------------, x[22] = 0, x[23] = 1, x[32] = -1, 
        1                                                  
      - - Pi + 2 Pi _Z8                                    
        2                                                  

           \ 
  y[21] = 0| 
            >
           | 
           / 

> nops({SOL});
                               8

seq(simplify(eval({fff},teqs union {x[31]=0})),teqs in {SOL});
             {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}

And of course by the symmetry of Matrices `c` and `h` in `eq` we also have to check the following. (There are some solutions unique to each set, where x[31]<>0 or x[23]<>0.)

SOL2:=solve(eval({fff},[x[23]=0]),AllSolutions);
 /     1                                             \   
{ T = ---, x[22] = 1, x[31] = 0, x[32] = 1, y[21] = 0 }, 
 \    _Z9                                            /   

   /     1                                              \   
  { T = ----, x[22] = 1, x[31] = 0, x[32] = 1, y[21] = 0 }, 
   \    _Z10                                            /   

   /     1                                              \   
  { T = ----, x[22] = 1, x[31] = 0, x[32] = 1, y[21] = 0 }, 
   \    _Z11                                            /   

   /     1                                              \   
  { T = ----, x[22] = 1, x[31] = 0, x[32] = 1, y[21] = 0 }, 
   \    _Z12                                            /   

   /     1                                              \   
  { T = ----, x[22] = 1, x[31] = 0, x[32] = 1, y[21] = 0 }, 
   \    _Z13                                            /   

   /     1                                              \    /
  { T = ----, x[22] = 1, x[31] = 0, x[32] = 1, y[21] = 0 }, { 
   \    _Z14                                            /    \

           2 Pi                                                  
  T = --------------, x[22] = 1, x[31] = 0, x[32] = -1, y[21] = 0
      Pi + 2 Pi _Z15                                             

  \    /         2 Pi                                         
   }, { T = --------------, x[22] = 1, x[31] = 0, x[32] = -1, 
  /    \    Pi + 2 Pi _Z16                                    

           \    /         2 Pi                             
  y[21] = 0 }, { T = --------------, x[22] = 1, x[31] = 0, 
           /    \    Pi + 2 Pi _Z17                        

                       \    /         2 Pi                  
  x[32] = -1, y[21] = 0 }, { T = --------------, x[22] = 1, 
                       /    \    Pi + 2 Pi _Z18             

                                  \    /         2 Pi       
  x[31] = 0, x[32] = -1, y[21] = 0 }, { T = --------------, 
                                  /    \    Pi + 2 Pi _Z19  

                                             \    /
  x[22] = 1, x[31] = 0, x[32] = -1, y[21] = 0 }, { 
                                             /    \

           2 Pi                                                  
  T = --------------, x[22] = 1, x[31] = 0, x[32] = -1, y[21] = 0
      Pi + 2 Pi _Z20                                             

  \    /     1                                              \   
   }, { T = ----, x[22] = 1, x[31] = 1, x[32] = 0, y[21] = 1 }, 
  /    \    _Z21                                            /   

   /     1                                                \    /
  { T = ----, x[22] = 1, x[31] = -1, x[32] = 0, y[21] = -1 }, { 
   \    _Z22                                              /    \

           2 Pi                                                  
  T = --------------, x[22] = 1, x[31] = 1, x[32] = 0, y[21] = -1
      Pi + 2 Pi _Z23                                             

  \    /         2 Pi                                         
   }, { T = --------------, x[22] = 1, x[31] = -1, x[32] = 0, 
  /    \    Pi + 2 Pi _Z24                                    

           \    /         2 Pi                  
  y[21] = 1 }, { T = --------------, x[22] = 1, 
           /    \    Pi + 2 Pi _Z25             

                /  2    \                           /  2    \\   
  x[31] = RootOf\_Z  + 3/, x[32] = 2, y[21] = RootOf\_Z  + 3/ }, 
                                                             /   

   /     1                             /  2    \              
  { T = ----, x[22] = 1, x[31] = RootOf\_Z  + 3/, x[32] = -2, 
   \    _Z26                                                  

                 /  2    \\ 
  y[21] = -RootOf\_Z  + 3/ }
                          / 

> nops({SOL2});
                               18

> seq(simplify(eval({fff},teqs union {x[23]=0})),teqs in {SOL});
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, 

  {0}, {0}, {0}, {0}, {0}

acer

You can either not use Units:-Standard:-`^` and keep the float powers, or you can use rational powers.

For the first of those, note that you can get all of Units:-Standard loaded excepting some individual parts such as its `^` export. For example,

> restart:
> with(Units[Standard]): unwith(Units:-Standard,`^`):

> n:=1.38:
> p1:=1.1*Unit(bar):
> v1:=3*Unit(dm^3):
> v2:=0.4*Unit(dm^3):

> v1^n;
               4.554359738 ['dm'^3]^1.38

> p2:=(p1*v1^n)/(v2^n);
               17.74096457 ['bar']

Notice how the exponents in v1^n do not simplify above. I doubt that one could get them to combine using `simplify`, either.

For the second of those two approaches mentioned, you can either just enter everything youself as pure rationals (eg. 1.38 = 138/100, etc) or you can convert them with Maple (either once up front, or on-the-fly).

> restart:
> with(Units[Standard]):

> n:=1.38:
> p1:=1.1*Unit(bar):
> v1:=3*Unit(dm^3):
> v2:=0.4*Unit(dm^3):

> R:=t->convert(t,rational):

> evalf( (R(p1)*v1^R(n))/(R(v2)^R(n)) );
                             6                  
               1.774096458 10  ['Pa']

acer

You don't have MYPLOT as the return value of your procedure. So the plotobj argument doesn't get displayed or "printed".

You can work around that in a few ways. One way might be to assign MYPLOT to a local, then reset the 'default' plot options, and then to return that local as the last line of the procedure.

Or you could do it like this,

resizeMYPLOT := proc(plotObj)
   plotsetup('jpeg', 'plotoutput' = "c://temp/bar.jpg",
             'plotoptions' = "height=1000,width=1000");
   print(plotObj);
   plotsetup('default');
   NULL;
end proc:

plot(cos(x),x=-12..12);
resizeMYPLOT(%);

acer

I tried copying from and pasting to various Components' properties fields successfully on 64bit Maple for Windows 7 using Ctl-x, Ctl-c, and Ctl-v. Those keyboard shortcuts worked for me.

acer

I wasn't sure which it is of mol or m^3 that you want to get automatically changed into NM3. Below, I'll take it as mol which you want handled that way. Presumably you want anything which would otherwise return involving mol to instead return involving NM3. Is that right?

First, one can add a new unit. After that, then you can do things like convert(..,units,mol/sec,NM3/sec).

But you can also add a new system, which is a version of SI which uses NM3 instead of mol for the dimension of `amount_of_substance`.

> restart

> Units:-AddUnit(NM3,conversion=22.413*1000*mol,context=SI,prefix=SI);

> convert(20, units, mol, NM3);

                        0.0008923392674

> Units:-AddSystem(MySI,Units:-GetSystem(SI),NM3);
> Units:-UseSystem(MySI):

> with(Units[Natural]):

> 15*10^5*mol/sec;

                           [[  NM3   ]]
               66.92544506 [[ ------ ]]
                           [[ second ]]

If I may, I advise using Units[Standard] instead of Units[Natural]. I believe that the latter is a design mistake, basically robbing one of most all single letters (which otherwise come in useful for other purposes). It can also lead to confusion. Note that Units[Standard] can be used without need for having the name of the Unit() constructor appear in 2D Math input -- palette entry or command-completion can directly get the double-bracket unit appearance for 2D Math input.

acer

There is no easy way to get such fine grained display of intermediary steps for all manner of calculations.

But if you are able to do the requisite programming then you can sometimes coerce Maple into emulating such an environment.

Fo example see here or here.

acer

First 285 286 287 288 289 290 291 Last Page 287 of 337