mbras

52 Reputation

8 Badges

3 years, 324 days

MaplePrimes Activity


These are questions asked by mbras

Does anyone know why the following gives an error of invalid loop statement termination?

if true then
  for i from 1 to 2 do
  end do
else
end if

while putting a semicolon after `end do' fixes it.

This seems to only occur in if else statements, when end do appears directly before the else

I'm trying to define a monomial order - Monomials are first compared by their weighted degree, with ties broken by pure lexiocraphic order (plex). I want the monomial order just to find the LeadingTerm of polynomials.

Maple has wdeg(W,V) as a built in monomial order, which compares monomials first by their weights, but breaks ties using reverse lexicographic order (tdeg).

One way I could plausibly do this is using the 'matrix' constructor, and defining the plex order by a succession of weights, but this seems like overkill, and I would have a n*n matrix, where I'd like n to reach over 1000.

Is anyone aware of a simple way of defining such a monomial order?

I believe I've found a bug, where Eigenvectors returns two eigenvectors which are the same (even though the eigenvalues are different). The expressions involves RootOf's, and it seems that the eigenvalues use "index" to distinguish themselves, yet the eigenvectors do not.

with(LinearAlgebra);

x := RootOf(z^2-t, z);
m := Matrix(2, (i,j) -> evala(add(a[j, k]*((-1)^(i-1))^k*x^k, k = 0..1)));
ev := Eigenvectors(m);

Does anyone know how the sum command works? If I set

f:=proc(x) if x<=1 then 1 else 2

then compute

sum(f(i),i=1..10)

I get an error, as it tries to check "i<=0", for the symbol 'i'. Curiously if the comparison in 'f' is "x=1" it goes through fine. Another place this comes up is using "op" on lists. If I set

z:=[[1,2],[3,4],[5,6]]

then compute

sum(foldl((x,y)->x*vars[y],1,op(z[i])),i =1..3)

it doesn't give the desired answer. When i=1 for example, I think it computes op(z[i]) as op(z[i])->i->1, rather than op(z[i])->op(z[1])->op([1,2])->1,2.

Using convert(f,elsymfun) when f is a symmetric polynomial will write it in terms of elementary symmetric polynomials. For example, x^2+y^2 would become (x+y)^2-2x*y. For this command not to return an error, f must be symmetric, equivalently of type symmfunc(all indeterminants in expression).

I'd like to use this in a broader sense, when there are extra variables hanging around. For example, suppose f is a polynomial in a,b,c,x,y,z, and symmetric in x,y,z, so that type(f,symmfunc(x,y,z)) returns true. Then it is still possible to write this in terms of the elementary symmetric polynomials on x,y,z (with coefficients taken being rational polynomials in a,b,c).

For example, a+x^2+y^2 can be written as a+(x+y)^2-2x*y.

Is there a command available for this? Or is there a roundabout way to make Maple forget temporarily that a,b,c are indeterminants, before putting them back in after?

Thanks

1 2 Page 1 of 2