acer

32358 Reputation

29 Badges

19 years, 331 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

kernelopts(version);
         Maple 9.51, IBM INTEL LINUX, Aug 9 2004 Build ID 163356

eliminate({x[5] = x[2] / x[1], x[6] = x[3] / x[2], x[7] = x[1] / x[4],
           x[8] = (2 * x[2] + x[4]) / (2 * x[1] + x[3] + x[4])},
           {x[1], x[2], x[3], x[4], x[8]}):

lprint(%);
[{x[1] = x[7]*x[4], x[8] = (2*x[5]*x[7]+1)/(2*x[7]+x[6]*x[5]*x[7]+1),
  x[2] = x[5]*x[7]*x[4], x[3] = x[6]*x[5]*x[7]*x[4], x[4] = x[4]}, {}]

Between version 9.5.1 and 10.00 the procedure `eliminate/recursive` changed quite a bit.

kernelopts(version);
         Maple 10.00, X86 64 LINUX, May 13 2005 Build ID 190196

eliminate({x[5] = x[2] / x[1], x[6] = x[3] / x[2], x[7] = x[1] / x[4],
           x[8] = (2 * x[2] + x[4]) / (2 * x[1] + x[3] + x[4])},
           {x[1], x[2], x[3], x[4], x[8]});
                           NULL
kernelopts(version);
         Maple 2017.3, X86 64 LINUX, Sep 27 2017, Build ID 1265877

solve({x[5] = x[2] / x[1], x[6] = x[3] / x[2], x[7] = x[1] / x[4],
       x[8] = (2 * x[2] + x[4]) / (2 * x[1] + x[3] + x[4])},
       {x[1], x[2], x[3], x[4], x[8]}):

lprint(%);
{x[1] = x[7]*x[4], x[2] = x[5]*x[7]*x[4], x[3] = x[6]*x[5]*x[7]*x[4],
 x[4] = x[4], x[8] = (2*x[5]*x[7]+1)/(x[5]*x[6]*x[7]+2*x[7]+1)}

The last time that it calls itself on that example in Maple 2017.3, `eliminate/recursive` is passing the empty list {} as the first argument. Perhaps it ought to be doing some additional/modified check before doing that?  I have not studied it recently.

The PolyhedralSets package was introduced in Maple 2015, the major release right after Maple 18.

You could either convert those inequalities to RealRange (using the convert command).

Or you could call solve without the braces around the second argument. For example,

restart;

S1 := `union`( solve( x^2-3*x+2 <= 0, x ) );

RealRange(1, 2)

S2 :=`union`( solve( x^2-3*x+2 >= 0, x ) );

`union`(RealRange(2, infinity), RealRange(-infinity, 1))

lprint(S1);

RealRange(1, 2)

lprint(S2);

RealRange(2, infinity) union RealRange(-infinity, 1)

is( 3/2 in S1 );

true

is( 3/2 in S2 );

false

 


Download RealRange_solved.mw

 

I believe that the parametrizing approach that vv has shown is very likely best, for simplicity and overall quality.

But for fun I'll show that another approach, using the range functionality of the usual cartesian parameters.

It's key to note that the surfaces in question can be split up into (at least two) pieces, where each is the plotted surface of a function. I mean function in the usual mathematical sense, where each (x,y) point produces just one z-value. Hence instead of using implicitplot3d and we can just stitch together those various pieces.

I'm going to split each of the sphere and the ellipse into four such pieces. I'm pretty sure that it could be done in just two (using conditionals, or piecewise, or min/max calls in the ranges) but maybe not worth the extra effort.

One of the downsides to having to stitch together various pieces is that often either the seam shows (slightly darker due to miniscule overlap) or very tiny pinhole gaps show under manual rotation. Even the parametric approach shows a slight seam. But here -- with the radicals that come from solving these conics for particular valiables -- any slight amount of numeric error can lead to these effects being noticably worse.

The reason both the parametric and this approach work is that they both generate MESH plotting structures where the (x,y) data points can be arbitrary and irregular. And so they can follow 3d surface edge, smoothly. In contrast the regularly spaced GRID plotting structure can display with ragged edges and gaps where some evenly spaced (x,y) vertex fails to produce a real z-value (because the value there is undefined or imaginary).

Anyway, without much clean-up, and a few small numeric adjustments to keep the radicals behaved: Intersecting_surfaces_a3.mw

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

First 185 186 187 188 189 190 191 Last Page 187 of 336