acer

32333 Reputation

29 Badges

19 years, 325 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You didn't upload your data file (you can just zip it, and fake the extension, btw...) so I have to guess as to how you made and saved it.

But here is the result of a little experiment, using 64bit Maple 17 for Windows 7.

restart;

# Import it, with all entries imported as strings.
#
M := ImportMatrix(cat(kernelopts(homedir),"/My Documents/mapleprimes/md1.csv"),
                  delimiter=",",datatype=string);

                      ["Symbol"  "2015-08-15"  "2016-08-15"]
                      [                                    ]
                 M := [ "TFSC"      "9.76"        "9.62"   ]
                      [                                    ]
                      [ "PIH"       "7.63"        "7.57"   ]

# Strip off the restrictive string datatype.
#
M := Matrix(M, datatype=anything):

# Parse everything but the first column and row, to get numbers.
#
M[2..,2..]:=map(parse,M[2..,2..]):

M;

                   ["Symbol"  "2015-08-15"  "2016-08-15"]
                   [                                    ]
                   [ "TFSC"       9.76          9.62    ]
                   [                                    ]
                   [ "PIH"        7.63          7.57    ]

 

The file md1.zip contains the .csv file I used.

md1.zip

md1.mw

[edit] Now that the OP has uploaded a zipped .csv file, I checked and the above works the same on that data1.csv file.

acer

@jaypantone Do you see the same buffered/delayed effect for userinfo statements? (Those have the nice feature that you can turn them all on or off with a single command, and also control different levels of detail. They ought to display in a visually similar way in CLI and Std GUI)

Eg,

p := proc()
  userinfo( 1, p, `This is a userinfo statement`);
  userinfo( 3, p, `This is a level 3 a userinfo statement`);
  userinfo( 1, p, nprintf("This is a level %a userinfo statement,\nconstructed with nprintf", 1));
end proc:

p();

infolevel[p]:=3:
p();

infolevel[p]:=1:
p();

It's interesting that you don't see the delay problem with the `print` command. Here's a thought: does using `print` or `lprint` to print a single character string such as " ", interleaved with your delay-buffered `printf` statements, help at all?

Is this the kind of thing you want?

restart:

x:=[1992,1994,1996,1998,2000,2002,2004]:
y:=[325,310,266,217,178,159,161]:

Statistics[ColumnGraph](y,captions=[seq(sprintf("%a\n\n",_n),_n=x)]);

kernelopts(version);

          Maple 12.02, X86 64 WINDOWS, Dec 10 2008 Build ID 377066

acer

f := 5*A^4*B^3*C^7   +   3*A^2*B^1*C^7  +  31*A^3*B^6*C^11;

                          3  6  11      4  3  7      2    7
                 f := 31 A  B  C   + 5 A  B  C  + 3 A  B C 

Exponents := proc(p,x)
  local F;
  if p::`+` then
    [seq(degree(F,x), F in p)];
  else
    [degree(p,x)];
  end if;
end proc:

Exponents(f, A);
                                  [3, 4, 2]

Exponents(f, B);
                                  [6, 3, 1]

Exponents(f, C);
                                 [11, 7, 7]

Exponents(31*A^3*B^6*C^11, C);
                                    [11]

acer

If you want to call the LinearAlgebra package's commands with their short form names then at the start of your procedures include the statement,

uses LinearAlgebra;

For example,

f := proc(A)
  local res;
  uses LinearAlgebra;
  res := Basis(A);
end proc:

f( [<0,1,1>,<1,2,1>,<1,1,0>] );

                                 [[0]  [1]]
                                 [[ ]  [ ]]
                                 [[1], [2]]
                                 [[ ]  [ ]]
                                 [[1]  [1]]

If you are writing a module based package then you can do that within each of its procedures, be they exports or local (to the module) procedures.

Basically the `uses` statement sets up the relevant name bindings within your procedure, somewhat analogously to how `with` works at the top-level. (nb. `with` is not the thing to do, inside a procedure.)

The `uses` facility is documented in the Description section of the help-page for proc (procedure).

acer

restart:

limit((b^(d+1)-1)/((b-1)*b^d), d = infinity) assuming b>1;

                                      b  
                                    -----
                                    b - 1

limit((b^(d+1)-1)/((b-1)*b^d), d = infinity) assuming b<-1;  # hmm

                                  undefined

Q := simplify( (b^(d+1)-1)/((b-1)*b^d) ) assuming b<>1;

                                         (-d)
                                    b - b    
                               Q := ---------
                                      b - 1  

R := limit(Q, d = infinity) assuming b<-1 or b>1;

                                        b  
                                 R := -----
                                      b - 1

limit(Q, d = infinity) assuming b>=0 and b<1;

                                  infinity

limit(Q, d = infinity) assuming b>=-1 and b<0;

                                  undefined

What is going on as b->1 and d->infinity?

acer

Do you mean something like this? I am guessing that you want subscripts rather than underscores, which in your Maple 2015 can be done using a literal double-underscore.

plot( [[0,0]], labels=[Omega/omega__n,a__0(m)] );

If you want that m to be upright and not italic, you could do it as say,

labels=[typeset('Omega/omega__n'), typeset('a__0(`#mn("m")`)')]

acer

Is this the kind of thing you mean?

restart:

N := 50:

e2 := [seq(k*Pi/N, k=-N..N)]:
e3 := evalf(map(sin, e2)):

e4 := CurveFitting:-Spline(e2, e3, x):

PD := proc(p, v)
  local L;
  L:=convert(p, list);
  piecewise(seq([L[2*i-1],diff(L[2*i],v)][], i=1..floor(nops(L)/2)),
                diff(L[-1],v));
end proc:

de4 := PD(e4, x):

plot([e4, de4], x=-Pi..Pi);

 

acer

There is a call in the OpenMaple API for querying the interrupt signal. A lot of dsolve/numeric is in external compiled code, which could make use of that.

acer

Such a muddle of expressions and procedures.

Let's try it first with just expressions.

restart:
f := 2*t^3+9*t^2-60*t+1;
deq := diff(f,t);
plot(deq, t=-10..10);
isneg := min(deq,0);
plot(isneg, t=-10..10);
eval(isneg, t=0.12017234);

Now let's try it with procedures.

restart:
f := t -> 2*t^3+9*t^2-60*t+1;
deq := D(f);
plot(deq, -10..10);
isneg := x -> min(deq(x),0);
plot(isneg, -10..10);
isneg(0.12017234);

If you're going to muddle up the middle then you'll very likely have to remember what `unapply` does and when it's needed. See your `df` first "problem", where you've confused the formal parameter `t` of your created operator with the global `t` inside the expression `deq`.

restart:

f := proc (t) 2*t^3+9*t^2-60*t+1 end proc:

deq := diff(f(t),t):

df := t->deq;  ## "this is most likely one of my problems."

                          t -> deq

df(6);

                           2            
                        6 t  + 18 t - 60

df := unapply(deq,t);

                                2            
                        t -> 6 t  + 18 t - 60

df(6);
                              264

acer

I believe that Maple warning is emitted by the routine Optimization:-External:-E04NFA in the case that the integer return code (ifail) from the external NAG function e04nfa is equal to 1.

> kernelopts(version);

           Maple 2015.0, X86 64 LINUX, Feb 17 2015, Build ID 1022128

> showstat((Optimization::External)::E04NFA, 37..41);

(Optimization::External):-E04NFA := proc(x, istate, probtype, n, nclin, a, bl, bu, cvec, h, QPHESS, prmod)
local uselib, Extcall, lda, ldh, lcvec, clambda, liwork, iwork, ifail, lwork, work, obj, iter, iuser, ruser, ax;
       ...
  37   ifail := Extcall(n,nclin,a,lda,bl,bu,cvec,h,ldh,QPHESS,istate,x,'iter','obj',ax,clambda,iwork,liwork,work,lwork,iuser,ruser,op(prmod:-cb));
  38   if ifail = 1 then
  39     if probtype = "LP" then
  40       userinfo(1,'Optimization',`non-unique global minimum found`)
         else
  41       Warnings:-Issue("necessary conditions met but sufficient conditions not satisfied")
         end if
       elif ifail = 2 then
         ...
       elif ifail = 3 then
         ...
       elif ifail = 4 then
         ...
       elif ifail = 5 then
         ...
       elif ifail = 6 then
         ...
       elif ifail = 7 then
         ...
       elif ifail = ('Undefined') then
         ...
       elif ifail = 0 then
         ...
       else
         ...
       end if;
       ...
end proc

For a more detailed explanation of that return code you could look at Section 6 "Error Indicators and Warnings" on this e04nfa documentation page, where it describes IFAIL=1.

acer

The value of exp(10^3) is outside the range of double precision floats, which is a retsriction on the plot dirver.

evalhf(DBL_MAX);
                                         307
                    9.9999999000000001 10   

evalhf(log10(ln(DBL_MAX)));
                      2.85076640519378355

evalhf(exp(10^2.8507664051937835));
                                         307
                    9.9999965783395444 10   

evalhf(exp(10^3));
                        Float(infinity)

Some years ago I made a post about some effects of such restrictions (which affects other products as well).

acer

As an instructor you can set up a private group on the Maple Cloud, and have your students open worksheets Maple or the MaplePlayer directly from that. And one can access such material via a URL with a browser, too.

Historically the Maple Cloud has been Java based. But Maple TA (now v.10) has already been moving to HTML5. And so has MapleNet. (Those two links both mention not needing Java plugins, with some or all of the tech being HTML5.)

And there are bits of it in the source of the MathApps when viewed by browser off of the Maple Cloud via www.maplecloud.com. The post about the MapleCloud Online cited above uses the words, "No plugins. No Java."

acer

restart:         

with(Statistics):

X:=RandomVariable(Normal(0,1)):

M:=Matrix(2,3,datatype=float[8]):          
Sample(X,M):                   

M;

       [-1.07242412799827     -0.617091936909790    -0.0254281280423846]
       [                                                               ]
       [-0.329077870547065    0.214466745245291      1.72882128417783  ]

V:=Vector[row](3,datatype=float[8]):
Sample(X,V):            

V;
          [-0.682128392597197, 0.0993787123287771, -2.22695780238860]

This is quite fast.

M:=Matrix(1000,1000,datatype=float[8]):          

CodeTools:-Usage( Sample(X,M) ):       
memory used=8.08KiB, alloc change=0 bytes, cpu time=51.00ms, real time=56.00ms, gc time=0ns

This syntax for inplace population of a float[8] Matrix/Vector has existed since Maple 16. It's also convenient since the Matrix/Vector can be reused and repopulated repeatedly. Prior to that it was still fast to use Sample with an explicit size arument instead of the inplace syntax, and then one could ArrayTools:-Reshape to get a particular container type.

Since Maple 17 the dimensions of a Matrix result can also be supplied (non-in-place syntax) as follows, using the same X from before,

Sample(X, [3,2]);              

                  [-1.07242412799827      0.214466745245291 ]
                  [                                         ]
                  [-0.329077870547065    -0.0254281280423846]
                  [                                         ]
                  [-0.617091936909790     1.72882128417783  ]

whattype(%);
                                    Matrix

On my 64bit Linux on an Intel i5 it is 600 times slower to create a 1000x1000 entry float[8] Matrix using the Sample command in the first way above,

Matrix(1000, RandomTools[Generate](distribution(Normal(10,3)),
                                   makeproc=true),
       datatype=float[8]):

acer

convert(1.0, units, poundforce, slug*foot/second^2);

                                     1.0

convert(1.0, units, poundal, pound*foot/second^2);

                                     1.0

convert(1.0, units, poundforce, newton);

                                 4.448221615

convert(1.0, units, poundal, newton);

                                0.1382549544

And if you did not known the name poundal in advance,

convert( newton, system, FPS );

                         125000000000              
                         ------------ Unit(poundal)
                         17281869297


convert( force, system, FPS, dimension=true );

                                Unit(poundal)

acer

First 221 222 223 224 225 226 227 Last Page 223 of 336