sursumCorda

742 Reputation

13 Badges

1 years, 2 days

MaplePrimes Activity


These are questions asked by sursumCorda

According to the documentation of MmaTranslator:-Mma:-PolynomialReduce, this command yields . However, 

restart;
MmaTranslator:-Mma:-PolynomialReduce(x**2+y**2,{x-y,y+a});
 = 
                       [         2    2]
                       [[0, 0], x  + y ]

In[1]:= PolynomialReduce[x^2+y^2,{x-y,y+a}](*Mathematica*)

Out[1]= {{x + y, -2 a + 2 y}, 2 a^2}

In SymPy and in MuPAD: 

The output of both is the same as that of Mma; only the result given by Maple is inconsistent with Mathematica's. 

The example above is so simple that the desired result can be found simply by hand. Here is a larger example: 
Given two polynomials .txt and .txt, as well as a list of polynomials .txt, I would like to evaluate 

# Suppose that one has downloaded these three files. 
poly1, poly2 := fscanf("poly1.txt", "%a")[], fscanf("poly2.txt", "%a")[]:
pList := MmaTranslator:-Mma:-ReadList("pList.txt"):
MmaTranslator:-Mma:-PolynomialReduce((a - poly1)*(a - poly2), pList);

 But its result is just “[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ]”, while when a=0 it should be “[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 1, 0, 0, 0, 1, 2, 1, 0, 2, 2, 3, 1, 1, 1, 2, 1, 0, 0, 0, 1, 1, 2, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0], 0]”.
So why does  return a distinct value?

In an old question, @mbras asked for a "partial" `convert/elsymfun`. However, SymPy's sympy.polys.rings.PolyElement.symmetrize seems to provide more examples that cannot be handled by the program that appeared in that question.
For instance, 

>>> from sympy import var
>>> var('x:z,p:r')
(x, y, z, p, q, r)
>>> from sympy.polys.polyfuncs import symmetrize
>>> symmetrize(x**2-(y**2+2**z),[y,x],formal=True,symbols=[p+p,q*q])[0]
-2**z - 4*p**2 + 2*q**2
>>> symmetrize(x*x*y+y*y*z+z*z*x,[y,x,z],formal=True,symbols=[p,q,r])
(0, x**2*y + x*z**2 + y**2*z, [(p, x + y + z), (q, x*y + x*z + y*z), (r, x*y*z)])

Though I can , can't the built-in  be generalized to such expressions (in other words, write the polynomial part of input as a symmetric part and a remainder with (named, if need be) elementary symmetric polynomials)?

Besides, since any symmetric polynomial can also be expressed in terms of the complete symmetric polynomials, is there a similar  command in Maple?

Why does _EnvLinalg95 only affect  (and ) and not and ? 
 

restart;

m := <3 , 4 | 4 , 3>;

m := Matrix(2, 2, {(1, 1) = 3, (1, 2) = 4, (2, 1) = 4, (2, 2) = 3})

(1)

LinearAlgebra:-Eigenvalues(m);

Vector(2, {(1) = 7, (2) = -1})

(2)

LinearAlgebra:-Eigenvectors(m);

Vector(2, {(1) = -1, (2) = 7}), Matrix(2, 2, {(1, 1) = -1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1})

(3)

LinearAlgebra:-EigenConditionNumbers(m);

Vector(2, {(1) = 1.00000000000000, (2) = 1.00000000000000}), Vector(2, {(1) = 8., (2) = 8.})

(4)

_EnvLinalg95 := true:

whattype(m);

Matrix

(5)

LinearAlgebra:-Eigenvalues(m);

Vector(2, {(1) = 7, (2) = -1})

(6)

LinearAlgebra:-Eigenvectors(m):

Error, (in Matrix) invalid input: `Matrix/MakeInit` expects its 1st argument, initializer, to be of type list(list), but received [proc (i, j) options operator, arrow; `if`(j = 1 and i <= 2, (Vector(2, {(1) = 1, (2) = 1}))[i], rhs(fill_opt)) end proc]

 

LinearAlgebra:-EigenConditionNumbers(m);

Vector(2, {(1) = 1.00000000000000, (2) = 1.00000000000000}), Vector(2, {(1) = 8., (2) = 8.})

(7)

_EnvLinalg95 := false:

LinearAlgebra:-Eigenvectors(m);

Vector(2, {(1) = -1, (2) = 7}), Matrix(2, 2, {(1, 1) = -1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1})

(8)


 

Download _EnvLinalg95.mw

I have read the help page of Eigenvectors but couldn't find anything related.

There seems to be a consensus about using ListTools:-SearchAll to locate an item in a list. However, this subroutine does not work on other expressions; A simple instance is that “ListTools:-SearchAll(1, [[1], 1]);” only outputs  while what I need is  (because both “op([1, 1], [[1], 1])” and “op([2], [[1], 1])” are ). And actually, I hope that there is a more general version in Maple.
For example, I intend to do something like 

restart;
expr, elem := ToInert(eval(`print/Diff`)), '_Inert_NAME'("_syslib"):
SearchAll(elem, expr);

and 

List:=[[[[cS,[[[cS,cS],cS],[[[cS,cS],[[cK,cK],cS]],cS]]],cS],cS],[[[cS,[[cK,cS],cK]],cK],cS]]: 
items:=Or([[[identical(cS),anything],anything],anything],[[identical(cK),anything],anything]): 
SearchAll(items,List); 

In other words, I need all positions of an operand of an expression (cf. op).

It may be manually checked that the "indices" of  in  include [5,1,1,2,1,1,1,2,1,2,1,2], [5,1,2,2,1,1,1,1,2,1,2], and [5,2,2,1,1,3,1,2], since 

patmatch(op([5, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2], expr), elem);
 = 
                              true

patmatch(op([5, 1, 2, 2, 1, 1, 1, 1, 2, 1, 2], expr), elem);
 = 
                              true

patmatch(op([5, 2, 2, 1, 1, 3, 1, 2], expr), elem);
 = 
                              true

Similarly, after some manual searchs, 

[[1], [1, 1, 1, 2], [1, 1, 1, 2, 2], [1, 1, 1, 2, 2, 1, 2], [2], [2, 1, 1, 2]]:
convert(typematch~(map2(`?[]`, List, `%`), items), `and`);
 = 
                              true

It turns out that all "indices" in  of  are [1][1,1,1,2][1,1,1,2,2][1,1,1,2,2,1,2][2], and [2,1,1,2].
But isn't there such a  command that can eliminate the need to manually retrieve them?

In an old question, @nm asked how to . While the answer in that question was almost up to the mark, there remains a regret. 

As the instance listed below shows, Maple, by default, draws arrows on a rectangular grid (rather than on a hexagonal mesh): 

  # Example of a three-dimensional vector field: 
vf__2d := VectorCalculus:-VectorField([sin(x)*(cos(x) + cos(y)), 
                                       sin(y)*(cos(x) - cos(y))], 'cartesian'[x, y]):
  # Example of a two-dimensional vector field: 
vf__3d := VectorCalculus:-VectorField([1 - (sin(u - v) + sin(u - w)), 
                                       1 - (sin(v - w) + sin(v - u)), 
                                       1 - (sin(w - u) + sin(w - v))], 'cartesian'[u, v, w]):
  # Phase portrait. 
Student:-VectorCalculus:-PlotVector(vf__2d, (x, y) =~ -Pi .. Pi, 
                                            'grid' = [`$`](25, 2), 
                                          'arrows' = 'THICK', 
                                   'fieldstrength' = log[63], 
                                           'color' = ColorTools:-Color("#0072BD"), 
                                            'axes' = "box"(*, …omitted…*));
= 

Note that I have changed some of the options in order to make the layout of arrows more prominent.
However, according to the help page of Mma's VectorPoints, among the following methods of location generation, Mma by default uses Hexagonal for 2D field vectors and FaceCenteredCubic for 3D field vector: 

Here is a collection of different settings available in Mma:

So if the requirement is to get the Maple's output looking like Mathematica's (see the beginning), the number and placement of vectors to plot should be thought of as well. In Maple, “the number of vectors” can be controlled by the plot (or plot3d) opinion , but how do I specify “the placement of vectors” (e.g., Mma's "Hexagonal" and "Mesh")?

Although there exists an  chapter in the documentation, randomly positioned arrows do not fit the bill. Is there any workaround?

1 2 3 4 5 6 7 Last Page 1 of 16