Mr. Roman Pearce

1678 Reputation

19 Badges

19 years, 182 days
Research Associate
Abbotsford, British Columbia, Canada

I am a research associate at Simon Fraser University and a member of the Computer Algebra Group at the CECM.

MaplePrimes Activity

These are answers submitted by roman_pearce

You can try using higher level constructs like map, seq, or add instead of loops, and then using Threads:-Map, Threads:-Seq, or Threads:-Add.  It's hard to predict how well that will work.  A better option might be to use the task model and make the body of your loop a task.  See the help page ?Threads,Task

@Carlo Carminati 

Every time you do C := [op(C), ..]  it is going to copy all of C.  That will make your program slow.  You need to use tables like in the following example:

C := table():
nc := 0;
for i from 1 to 10 do
  C[i] := i;  # any value
  nc := nc + 1;
end do;

Can you check the memory usage of the mserver process?  That's the Maple kernel.  I think you're just seeing the interface which is a separate process.


J := <x^2-1>;

K := <x-1>;

IsPrime(J);  # false

L := Quotient(J,K);

IsPrime(L);  # true

Use the dsolve command to solve differential equations and systems.

In the command line version I don't know how to do it.  In the GUI you can right click the equation and select "NumericFormatting..." and it should work.  Is that giving you an error?

For a polynomial system with rational number coefficients, you might try the RationalUnivariateRepresentation command.  In general, the algorithm used by UnivariatePolynomial is not that fast.

Wow this is a blast from the past.  Use groebner not std, as it will use a linear algebra method or the Groebner walk.

-bash-4.1$ singular
A Computer Algebra System for Polynomial Computations / version 3-1-0
by: G.-M. Greuel, G. Pfister, H. Schoenemann \ Mar 2009
FB Mathematik der Universitaet, D-67653 Kaiserslautern \
> ring r=(0,a,b),(y,x),lp;
> ideal I=a*x^3-3*x*y+b,x^2*y-2*y^2+x;
> groebner(I);
> groebner(I)[1];
> poly f = groebner(I)[1];
> f;

The results are likely to be huge, and the coefficients (in 12 parameters) of the univariate polynomials will be too large to be useful.  You should plug in values for the parameters if possible.

PrimeDecomposition returns prime ideals whose intersection is the radical of the given ideal.  Prime ideals do not factor and do not have multiple roots.  PrimaryDecomposition returns primary ideals whose intersection is the original ideal.  These do not factor properly, but may have multiple roots.  This is best illustrated with an example.  The Simplify command shows a Groebner basis.  Without Simplify, you will get the original generators plus some new polynomials in each component.

J := <x^2*y^2>;

For most arithmetic use mod:

f := 5*x^2 + 2*x - 3;

f mod 2;

Expand(f*f) mod 11;

There really should be a command for this.  Explanation follows, but G[1] is your polynomial.

G := Groebner:-FGLM([a^4+a+1, x-a^3], plex(x,a), plex(a,x), characteristic=2);

The problem maps nicely onto an elimination of variables.  Given the field equation a^4+a+1=0 and the relation a^3=x, we construct a polynomial system and eliminate a to obtain a polynomial in x only.  It just so happens that these equations have a particularly nice form.  In general, if you had a big mess you could do the following, and Maple would try to figure out the best way to eliminate variables:

G := Groebner:-Basis([a^4+a+1, x-a^3], plex(a,x), characteristic=2);

In this case though you have a triangular system of equations in which each variable appears as the largest term of one equation.  This is a lex Groebner basis with x > a.  The command at the top applies a linear algebra method for converting Groebner bases, literally searching for linear dependencies among the powers of x=a^3.  It finds one at x^4.

It uses sparse linear algebra.  It should be reasonably fast.

Applications create threads but have no control over how or when they are run.  Those decisions are made by the operating system scheduler.  In general you're going to need to know how that works, and then you can use tools to assign priorities to achieve something like the desired result. What you are specifically asking to do is probably not possible outside of a real-time OS.  In general you have much less control over how things are run, unless you use Linux and write your own operating system scheduler.

Keep in mind that the time command measures total cpu time, which is typically higher for parallel programs.  The time[real]() command will measure elapsed wall time, as in:

restart: with(Threads):

Statistics[Mean]([seq(time[real](add(1/i, i = 1 .. 50000)), j = 1 .. 10)]);

Statistics[Mean]([seq(time[real](Add(1/i, i = 1 .. 50000)), j = 1 .. 10)]);

This example does not show good speedup.  I have in fact had trouble getting good speedup out of Threads:-Add and Threads:-Seq.  The task model generally works better.

Maybe you want a least squares approximation.  Here's a quadratic:

f := CurveFitting:-LeastSquares(points,x,curve=a*x^2+b*x+c);

P := plots:-pointplot(points);

C := plot(f,x=0..60);




3 4 5 6 7 8 9 Last Page 5 of 19