acer

32333 Reputation

29 Badges

19 years, 326 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

I've seen a few requests like this.

A similar weakness appears in the plots:-matrixplot command (when creating surfaces, not using its histogram features), but the alternative in that case is to use plots:-surfdata which allows you to specify the ranges over which to interpret the data. There is no easy alternative for plots:-listcontplot that I'm aware of.

But you can use the plottools:-transform command to rescale. It's a little work to create the transformer, but once you see the construction of trans below you'll see the idea, which is not complicated and straightforward to modify for other examples.

I also have a modified listcontplot which does this automatically. It also allows for interpolated refinement  of the data. I might dig that up.

restart;

Porig:=plots:-contourplot(sin(y)*x^2, x=0.3 .. 0.7, y=2.2 .. 3.7, style=point):
 

M:=Matrix(20,50,
          (i,j)->evalf( (0.3+(i-1)*(0.7-0.3)/(20-1))^2*sin((2.2+(j-1)*(3.7-2.2)/(50-1))) ) ):

 

You are starting with a numeric Matrix M.

 

Since you've asked for it to be displayed over [0.3..0.7]x[2.2..3.7] then

presumably you want M[..,1] to be interpreted as x=0.3 and M[..,20] to

be interpreted as x=0.7, and something analogous for y.

The Porig above was generated only for visual verification.

 

P1:=plots:-listcontplot( M ):
P1;

trans:=plottools:-transform((x,y)->[0.3+(x-1)*(0.7-0.3)/(20-1), 2.2+(y-1)*(3.7-2.2)/(50-1)]):
Pnew:=trans(P1):
Pnew;

Does Pnew agree with Porig? Let's see:

plots:-display(Porig, Pnew);

 


listcontplot_ranges.mw

 

You seem to be trying to configure the Maple 2017 Compiler to use a particular version of MSVC++ on Windows 64.

But why? Maple 2017 for 64bit Windows ships with its own bundled C compiler, utilized by its Compiler:-Compile command. (Since Maple 2015 all the 64bit Maple platforms have shipped with it.)

That stock un-reconfigured Compiler:-Compile doesn't complain when applied to your MinVal procedure. Do you have some reason to think that it's not working properly?

Are you sure that your code would run properly even without compiling MinVal? When I try the code (without compiling MinVal) I get an error from Iterator:-SetPartitions that seems unrelated.

You didn't say which Maple version you're using. This below is in Maple 2017.

restart;

Typesetting:-Settings(typesetdot=true):

Typesetting:-Settings(dot):  # `t` by default

diff( x(t), t ), diff( x(tau), tau );

diff(x(t), t), diff(x(tau), tau)

Typesetting:-Settings(dot=tau):

diff( x(t), t ), diff( x(tau), tau );

diff(x(t), t), diff(x(tau), tau)

 

 

Download usedot_tau.mw

Did you accidentally type a space between rod and [i,j] ?

It looks like you might also have accidentally typed extra spaces in several other places, such as between letters in simplify, and right after subs, and so on.

In default 2D Input mode Maple interprets those spaces as meaning multiplication.

Also, you need to call the simplify command with round brackets, as a function call (and not just insert a space).

@Markiyan Hirnyk 

restart;
M:=n->Matrix(n,  (i, j) -> binomial(a*i+b*j, j) ):

seq(print(coeffs(expand(numer(simplify(convert(LinearAlgebra:-Determinant(M(n)),factorial)))),[a,b])),n=1..6);

                          1, 1
                         2, 3, 1
                       6, 11, 6, 1
                    24, 50, 35, 10, 1
                 120, 274, 225, 85, 15, 1
            720, 1764, 1624, 735, 175, 21, 1

seq(print(seq(Stirling1(j,i),i=1..j)),j=2..7);

                          -1, 1
                         2, -3, 1
                      -6, 11, -6, 1
                   24, -50, 35, -10, 1
              -120, 274, -225, 85, -15, 1
          720, -1764, 1624, -735, 175, -21, 1

That OEIS sequence represents the concatenation of rows of a "triangle" of the Stirling1(i,j) numbers. That's why I wrote above of offsetting into the triangular collection in the OEIS sequence (because that can get one the sequence of Stirling(i,j) for a fixed `i`.)

lprint([seq(seq(Stirling1(i,j),j=0..i),i=0..9)]);

[1, 0, 1, 0, -1, 1, 0, 2, -3, 1, 0, -6, 11, -6, 1, 0, 24, -50, 35, -10,
 1, 0, -120, 274, -225, 85, -15, 1, 0, 720, -1764, 1624, -735, 175, -21,
 1, 0, -5040, 13068, -13132, 6769, -1960, 322, -28, 1, 0, 40320, -109584,
 118124, -67284, 22449, -4536, 546, -36, 1]

It is not difficult to find a formula using Stirling1(i,j) which matches the determinants M(i), including the powers of a and b and the signs and the factorial in the denominator. I did it at home this morning (soon after you posted this), but if you need me to give it in full it'd have to wait until when I get home again.

But such a formula is no proof of its correctness. Perhaps it may give someone inspiration (for the proof of that formula, not that formula itself).

[edited] Here is the unproven formula I arrived before, as a sum of n+1 terms involving Stirling1 calls. It takes a while to compute S(7) and higher.

restart;

M:=n->Matrix(n, (i, j) ->binomial(a*i+b*j, j) );

proc (n) options operator, arrow; Matrix(n, proc (i, j) options operator, arrow; binomial(a*i+b*j, j) end proc) end proc

S:=n->simplify(convert(LinearAlgebra:-Determinant(M(n)),factorial)):

Q:=(-1)^n*a^((n+1)*n/2)/n!*(Stirling1(n+1,1)+Sum((-1)^(i+1)*Stirling1(n+1,i)*a^(1-i)*b,i=2..n+1));

(-1)^n*a^((1/2)*(n+1)*n)*(Stirling1(n+1, 1)+Sum((-1)^(i+1)*Stirling1(n+1, i)*a^(1-i)*b, i = 2 .. n+1))/factorial(n)

seq( normal( S(k)-value(eval(Q,n=k)) ), k=1..7 );

0, 0, 0, 0, 0, 0, 0

 

Download Det_Stirling1.mw

[edited] And for anyone curious about using the coefficients to query the OEIS package (available from the maplecloud for installation directly from within Maple 2017, or installable directly from within Maple 2017 itself using the cloud tab): OEIS.mw

You can set the use of piticks and decimalticks without having to construct all the tickmarks explicitly.

restart; plots:-setoptions(gridlines=false):

plot(sqrt(arcsin(x)), x=0..1, tickmarks=[decimalticks, piticks]);

plots:-implicitplot(arcsin(x^2-y)=sqrt(y), x=-1..1, y=0..1,
                    gridrefine=5, tickmarks=[decimalticks, piticks]);

 


pi_decimal.mw

Those warnings are emitted by the Maple interface (whether it is the cmaple commandline interface or the Standard Java GUI), and not by the Maple kernel (computational engine).

If you don't want to see such parser warnings (while still seeing kernel and Library warnings) you can set,

interface(warnlevel=2):

I'm not sure what else to say. The commandline interface (aka CLI or TTY interface) and the Java GUI have their own separate parsing mechanisms, with a few differences.

One example of such differences includes that business you mentioned in your previous thread about trailing backslash as a continuation character. That was historically there to support the CLI and the plaintext `read`. In the GUI you can insert an additional line of code using Shift-Enter, without triggering execution of the line with just Enter. But in the CLI and text-based `read` that doesn't make physical sense. So in order to allow multiple line input (without typing just Enter and triggering execution) the CLI and test-based `read` support the trailing backslash as an indicator of statement continuation.

This warning you cite here is another difference in the interfaces.

You've already bothered to escape the backslash, with your posted version using "\\".

Now be consistent and handle the newline the same way, as an escape sequence. (...and similarly for the tab, if you want)

There's no need to use an extra blank space (which you might need to subsequently erase or deal with) at the end of a line which might otherwise end with a backslash (which Maple treats as a line continuation marker).

process_file := proc()
local str;

str:="\n\t\\begin{align*}\n\tA =& B \\\\\n\t=& 3\n\t\\end{align*}\n ";

FileTools[Text][WriteString]("output.txt", str);
FileTools[Text][Close]("output.txt");

end proc:

Also, if it helps you keep things more understandable (say, when dealing with longer strings), you can break it up by formatting it as follows. Here I'll also add in a few spaces you had originally, to indent like your original (though of course you could also replace all escaped tabs with spaces if you prefer that.)

process_file := proc()
local str;
  
str:="\n"
     "\t\\begin{align*}\n"
     "\t  A =& B \\\\\n"
     "\t    =& 3\n"
     "\t\\end{align*}\n ";

FileTools[Text][WriteString]("output.txt", str);
FileTools[Text][Close]("output.txt");

end proc:

And if you are building up the rhs of the assignment statement (for str) programmatically you could use the cat command on a comma-separated sequence of substrings.

This is much cruder than _Maxim_'s suggestion, but happens to work here.

I include some steps that are not necessary,
restart;

eu := -2*n^2*B^2+2*n*B^2*p-2*n*B^2*p^2+n*B^2-B^2*p+B^2*p^3+n*c*d:                          

algsubs(p^2=freeze(p^2-p+n)+p-n,
        expand(algsubs(p^3=freeze(p^3-p+n)+p-n,
                       expand(eu))));

                       2                2
                   -2 B  n freeze/R0 + B  freeze/R1 + c d n

collect(%,[freeze(p^2-p+n),freeze(p^3-p+n)]);

                       2                2
                   -2 B  n freeze/R0 + B  freeze/R1 + c d n

thaw(%);

                       2   2             2   3
                 -2 n B  (p  + n - p) + B  (p  + n - p) + n c d

Some of those apparent numbers in the input Matrix are not really numbers. But rather, they are just names that just look like the numbers, and so do not resolve mathematically. Some of the apparent zeroes in the input Matrix are lime that.

I've seen others have the same problem when using the Matrix palette, in particular with Maple 2017.

I suggest you manually delete the entries in the Matrix input, and then re-enter them.

Or use the `<<..>>` or Matrix commands instead of the palette to enter your Matrices. 

 

I don't really understand what rule you might be thinking of, for including terms like z^w .

But is this the kind of thing you mean? (It is not guaranteed to always produce "difference parametric coefficients", but most of the time it does.)

restart;

randomize():

gen_p:=proc(vars::list(name),
            params::list(name),
            {varterms::posint:=4,
             vardeg::posint:=2,
             paramterms::posint:=1,
             paramdeg::posint:=2,
             paramcrng::range(nonnegint):=1..10})
  local p_xyz,L,L_abc,L1_abc,L2_abc,t;
  p_xyz:=randpoly({x,y,z},'terms'=varterms,'degree'=vardeg);
  L:=coeffs(p_xyz, [x,y,z], 't');
  L1_abc:=[seq(randpoly({a,b,c},'terms'=paramterms,'degree'=paramdeg,
              'coeffs'=rand(paramcrng)),
              i=1..nops([t]))];
  L2_abc:=[seq(randpoly({a,b,c},'terms'=paramterms,'degree'=paramdeg,
              'coeffs'=rand(paramcrng)),
              i=1..nops([t]))];
  L_abc:=L1_abc-L2_abc;
  `+`(op(zip(`*`,L_abc,[t])));
end proc:

gen_p([x,y,z], [a,b,c,d]);

(2*a*c-2*b*c)*y^2-4*c^2*y*z+(-3*a^2+3*a)*y+3*b^2-b*c

gen_p([x,y,z], [a,b,c,d]);

(-10*a^2+5*a*c)*x*z+(-4*b*c+a)*y^2+(-2*c+2)*y*z+(-10*a+4*b)*z

gen_p([x,y,z], [a,b,c,d]);

(2*a*b-9*c)*x*z+(5*a^2-5)*y^2+(-6*a*c+9*c)*z^2-2*c*z

gen_p([x,y,z], [a,b,c,d],
      vardeg=3);

(-2*a*b+4*c)*x^3+(-9*a^2+b^2)*x^2*z+(7*a*b-2*a*c)*x*y^2+(-b^2+2*b)*x^2

gen_p([x,y,z], [a,b,c,d],
      paramdeg=3);

(7*a*c^2-4*b*c^2)*x^2+(-b^2+9*b*c)*y*z+(-3*a*b*c+3*c^3)*z^2-5*a^2*b+8

gen_p([x,y,z], [a,b,c,d],
      varterms=6);

(-10+2*c)*x^2+5*x*y+(-10*b*c+7*b)*y^2+(-6*a*c+3*c^2)*y*z+(2*b*c-2*c^2)*x+3*b^2-6*c

gen_p([x,y,z], [a,b,c,d],
      paramterms=4);

(7*a^2-a*c-8*a-2*b+6*c-6)*x^2+(a^2+a*b+5*b*c-2*c^2+6*a-10)*y^2+(-a^2+a*c-7*b*c-10*c^2-2*b+8*c+3)*x+4*a^2-2*a*b-b^2+8*b*c+c^2-4*b-5

gen_p([x,y,z], [a,b,c,d],
      vardeg=3,varterms=6,
      paramdeg=3,paramterms=4,
      paramcrng=0..99);

(14*a^3-70*a*b^2+39*a*b*c-25*b^3+82*a*b-18*a*c-50*b*c+45*c^2)*x^2*z+(-97*a*b^2+47*b^3-66*b^2*c+39*a*b-49*a*c+42*b*c+88*b-38*c)*x*z+(19*a^3+70*a^2*b-98*a*b^2-61*a*c^2-55*b^3+14*b^2*c+2*b*c^2-78*c)*y^2+(81*a^2*c-37*b^2*c-98*a^2-58*a*c+51*b^2+18*b*c+75*a)*y*z+(50*a^3+46*a^2*b-85*b^3+83*c^3+38*a*b-48*b)*z^2+(76*a^3-82*a^2*c-23*a*b^2-32*a*c^2-70*c^3+57*b^2+78*b*c+18*c)*y

 


Download param_poly.mw

sol := {x=12.0005, y=4.65}:

eval(x, sol);

eval(y, sol);

eval(x^2+y/5, sol);
restart;

expr := (M/(L*T))^a*(M/L^3)^b*(L^2)^c:

ans:=simplify(expr) assuming L>0, T>0:

ans;

               (-a - 3 b + 2 c)  (-a)  (a + b)
              L                 T     M

combine(expand(expr)) assuming L>0, T>0;

               (-a - 3 b + 2 c)  (-a)  (a + b)
              L                 T     M

combine(expand(expr)) assuming a::integer, b::integer, c::integer;

               (-a - 3 b + 2 c)  (-a)  (a + b)
              L                 T     M

combine(expand(expr)) assuming a::integer, L>0;

               (-a - 3 b + 2 c)  (-a)  (a + b)
              L                 T     M

eval([expr,ans],[a=1,b=1,c=1/4,M=1,T=1,L=-2.0]);

               [0.08838834762, 0.08838834765 I]

It is coincidence that op(0,e) happens to be the capitalized instance of the name of a type, for e being of numeric type such as integer, float.

Rather, op(0,e) for such things is the name of a constructor, such that op(0,e)( op(e) ) constructs e itself.

Eg,

op(0, 35.4);
                        Float

op(35.4);
                       354, -1

Float( 354, -1 );
                         35.4

op(0, 35.4)( op(35.4) )
                         35.4

op(0, 2/3);
                        Fraction

op(2/3);   
                          2, 3

Fraction( 2, 3 );
                           2/3

op(0, 2/3)( op(2/3) );
                           2/3

The construction calls Integer( -34 ) and op(0, -34)( -34 ) both produce 34 itself. That may not seem very exciting, but it is consistent with the other examples above.

op(0, -34);
                           Integer

op(-34);
                             -34

Integer( -34 );
                             -34

op(0, -34)( op(-34) );
                             -34

It is not the case that all expressions can be reconstructed like e = op(0,e)( op(e) ), but that is the case for the other types you mentioned: Vector, Array, Matrix, `+`.

Just because there is a constructing procedure that happens to produce an expression doesn't mean that it has to also be a type. It looks like you've simply made an incorrect interpretation of such things.

You might also look at the command whattype .

[edit] I finished this Answer before I saw Kitonum's Answer (which I've up-voted).

So you are using a call to Plotter from the Maplets[Elements] subpackage?

And you tried to pass

display(seq(S[n]$5, n=1..10), insequence=true)

as its first argument?

You could try this instead, as the first argument to Plotter.

PLOT(ANIMATE(seq([op(S[n])]$5, n=1..10)))

[edited] Since you mentioned the plots:-animate command, another possibility for that first argument to Maplets[Element][Plotter] might be something (clunkier) like say,

plots:-animate(plots:-display, [S[trunc(n)]$5],
               n=1..10, frames=50, paraminfo=false)
First 185 186 187 188 189 190 191 Last Page 187 of 336