acer

32405 Reputation

29 Badges

19 years, 346 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

If your working precision is too small then not all real roots of your degree 28 polynomial (that determinant, a polynomial in P) get their imaginary components resolved sufficiently close to zero as to be recognized as being purely real.

With Digits set only to 20 then only one real root gets resolved sufficiently (perhaps somewhat randomly).

You can see this a little more clearly by using fsolve on a complex box (rather than a real interval) and playing with the Digits setting.

At Digits=100 I get 28 real roots returned. Here I used Maple 2016.2, which you can upgrade your valid Maple 2016.0 to for free.

Stability_a.mw

I don't know of any 2D Input syntax that allows you to enter a Vector within a typeset radical and use the tilde to make that act elementwise.

I don't see that loading Units:-Standard is the problem here. What you had originally won't work even without that package loaded, AFAIK.

But you can do these:

restart

interface(imaginaryunit = I); with(Units[Standard]); with(plots)

`~`[sqrt](Vector(2, {(1) = 16., (2) = 9.}))

Vector[column](%id = 18446884219360117214)

`~`[proc (x) options operator, arrow; sqrt(x) end proc](Vector(2, {(1) = 16., (2) = 9.}))

Vector[column](%id = 18446884219360119254)

``

Download Elementwise_Square_Root_a.mw

Eigenvectors, Eigenvalues, and Determinant, etc are commands in the LinearAlgebra package.

It sounds like you may not calling the commands properly. In order to access them you have to either load the package by first doing

with(LinearAlgebra):

or call them by their long-form fully qualified name, eg,

LinearAlgebra:-Eigenvalues(M70);

and so on.

In contrast, issuing M70^(-1) or 1/M70 dispatches directly to LinearAlgebra:-MatrixInverse.

Another possibility is that you got a result but since the inputs weren't floats then the result contained RootOf placeholders. I suspect that's not actually the problem, but it's not possible to know for sure because you haven't attached a worksheet/document that exhibits the problem.

Have you tried,

setmaple('a', 10)
instead of just your,
a=10

You cannot get output like what you've described (ie. a mixture of upright text and 2D Output, and without separating commas) using the print command.

But you can still generate a procedure to assemble something which displays as output.

restart

kernelopts(version);

`Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895`

H:=proc()
  local oldlevel, temp;
  uses Typesetting;
  try
    oldlevel:=interface('typesetting'=':-extended');
    temp:=Typeset(EV(args));
    temp:=eval(temp,[mo(",")=NULL,ms=mn,
          mstyle(mo("and"),'mathvariant'="bold")=mn(" and "),
          mo("∧",msemantics="inert")=mn(" and ")]);
    temp:=subsindets(temp,And('specfunc'(mfenced),
                              satisfies(u->member(msemantics="realrange",
                                                  [op(u)]))),
                     u->mfenced(mrow(op(1,u),mo(";"),op(2,u)),
                                op(3..,u)));
  catch:
    return NULL;
  finally
    interface('typesetting'=oldlevel);
  end try;
  return temp;
end proc:

bt1 := 0 < x and x < (1/2)*Pi;

0 < x and x < (1/2)*Pi

f(x) = x-sin(x)

`%>`(f(x), f(0))

f(0) = 0

`%>`(x, sin(x))

RealRange(Open(0), Open((1/2)*Pi))

 

A fun idea is to get it to display the same regardless of the typesetting level.

 

interface(typesetting = standard):

"So, for 0<x<Pi/2 we have f(x)=x-sin(x)  and  `%>`(f(x),f(0))  and  f(0)=0, or `%>`(x,sin(x)), on the interval (0;Pi/2)"

interface(typesetting = extended):

"So, for 0<x<Pi/2 we have f(x)=x-sin(x)  and  `%>`(f(x),f(0))  and  f(0)=0, or `%>`(x,sin(x)), on the interval (0;Pi/2)"

 

# Ideally the unwanted `and` could be removed more carefully,
# for just the particular cases and without need for `` blanks.
H2:=proc()
  local oldlevel, temp;
  uses Typesetting;
  try
    oldlevel:=interface('typesetting'=':-extended');
    temp:=Typeset(EV(args));
    temp:=eval(temp,[mo("&comma;")=NULL,ms=mn,
          mstyle(mo("and"),'mathvariant'="bold")=NULL,
          mo("&and;",msemantics="inert")=mn("and")]);
    temp:=subsindets(temp,And('specfunc'(mfenced),
                              satisfies(u->member(msemantics="realrange",
                                                  [op(u)]))),
                     u->mfenced(mrow(op(1,u),mo(";"),op(2,u)),
                                op(3..,u)));
  catch:
    return NULL;
  finally
    interface('typesetting'=oldlevel);
  end try;
  return temp;
end proc:

ct1 := 0 < x and x < (1/2)*Pi;

0 < x and x < (1/2)*Pi

f(x) = x-sin(x)

`%>`(``, f(0))

`` = 0

`%>`(x, sin(x))

RealRange(Open(0), Open((1/2)*Pi))

H2("So, for ", ct1, " we have ", `and`(`and`(ct2, ct3), ct4), ", or ", ct5, ", on the interval ", ct6);

"So, for 0<x<Pi/2 we have f(x)=x-sin(x)  `%>`(,f(0))  =0, or `%>`(x,sin(x)), on the interval (0;Pi/2)"

 

Download typeset_math_text.mw

 

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

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