roman_pearce

Mr. Roman Pearce

1673 Reputation

19 Badges

18 years, 3 days
CECM/SFU
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

Use the Gcdex command mod n to compute inverses in your ring. For example, the Maple commands below assign the inverse of x^2+x+1 in Z[x]/(x^4-1) mod 11 to the variable s.
n := 11;
r := x^4-1;
f := x^2+x+1;
g := Gcdex(f, r, x, 's', 't') mod n;
Rem(s*f, r, x) mod n;
The Gcdex command runs the extended Euclidean algorithm to compute the gcd along with cofactors s and t with f*s + r*t = g mod n. Note that if the gcd is not 1 then your element is a zero-divisor and can't be inverted. The Rem command divides by r, producing a canonical representative for elements of your ring. To do these computations in characteristic zero, use the lower-case gcdex and rem commands.
You need a good vector graphics program, like Adobe Illustrator. Other programs are listed here. Note that there are some good free programs, like Inkscape, and Xara Xtreme has been opened up recently as well. One problem that you will find is that eps sucks, and Maple really needs to export SVG. For 3D plots your options are somewhat better. Maple can export POVRay files and Autocad DXF, however both will require you to re-render the plot in one of those programs.
One problem is that you need a multiplication sign between pairs of brackets. Maple interprets (f)(g) as the function f with argument g. Assuming your system is a set of rational functions, the numerators have the following sets of solutions: {{d121 = 1/b, d111 = 0, c = 0, d112 = 0, d122 = 0, d212 = 0, d221 = 0, s212 = 0, d222 = 1/b, d211 = 1/b, b = b}, {d221 = 0, a = 0}, {c = 0, d221 = 0, a = 0}, {d112 = -1/4*d111^2/d121, a = a, d111 = d111, d121 = d121, b = 1/d121, d122 = 0, d212 = 0, d221 = 0, s212 = 0, d222 = d121, c = -1/2*a*d111/d121, d211 = d121}, {d221 = 0, a = 0, b = 0}, {c = 0, a = 0, b = 0}}
The easiest way to solve a system of equations is to use the solve command. For example:
sys := { 3*x1 + 2*x2 + x3^2,  x2 - x3 + x4^2 };
solve(sys);
Try this first. Because many of your equations are linear, it should work. If it doesn't work (ie: it takes a long time) then you might try computing a Groebner basis. Groebner bases are a generalization of Gaussian elimination to nonlinear systems in multiple variables. In Maple 10 (only) you can do the following:
sys := {2*x1 + 3*x2 + ....};  # your system
G := PolynomialIdeals:-GroebnerBasis(sys, 'tord', 'plex'):   # compute lex basis
solve(G);
This will compute a Groebner basis using lexicographic order, automatically ordering the variables and so on. This basis G is much easier to solve, and the solve command should have no trouble with it. You can use this technique to solve moderately hard polynomial systems in Maple 10. In earlier versions of Maple Groebner basis computations are not as robust, and you have to choose the variable order. A good rule of thumb is to put the variables that appear in the highest degrees last in the order. So for example, if x1, x2, x3, ..., x14 are linear variables and x15 and x16 appear with degree 2, then put x15 and x16 last. The syntax to compute a Groebner basis is:
G := Groebner[gbasis](sys, plex(x1,x2,x3,...,x15,x16));
solve(G);
Hopefully something in here works for you. If not, you can post your system and I'll try to solve it.
Here are some examples to get you started. L := [0, 0.02, 0.5]; This creates a Maple list and assigns it to the variable L. Lists in Maple are actually stored internally as arrays (they are not linked lists), so accessing elements is constant time. The problem with lists is that you can't efficiently reassign elements one by one - it rebuilds the list each time. If you want to change all of the elements at once, you can use a seq or the map command and it will be efficient. In the example below, we will square all the elements of L, first by mapping a function onto L, then by using a sequence. L2 := map( x->x^2, L); L2 := [seq(i^2, i=L)]; L2[2]; # access second element Because you can't modify lists in place they are not appropriate for general linear algebra. Maple uses Vector and Matrix, which construct 1D or 2D arrays. Unlike lists, you can modify these structures in place. V := Vector(L); # make a Vector out of the list V := Vector([0, 0.02, 0.5]); # input a Vector directly A := Matrix([[1, 3, 0], [2, 0, 4]]); # make a Matrix A[1,3] := 2; # reassign element in row 1 column 3 A; # print You can also use the map command to apply functions to every element of a Vector or Matrix. If you are coming from Matlab probably the most important thing for you is using fast hardware floats. The Vector and Matrix above can contain any type of Maple object, for example, exact rational numbers or polynomials. Maple will detect when floating point numbers are present and use dedicated floating point routines, but that involves the overhead of checking every element in the matrix or vector. You can avoid this by declaring a datatype, as shown below. V := Vector(L, datatype=float[8]); When Maple encounters matrices and vectors with float[8] datatype, it doesn't waste any time doing anything. It just calls a compiled routine from the NAG (Numerical Algorithms Group) Library. You should get performance similar to Matlab for dense matrices. There is also some support for sparse matrices (in NAG format, with float[8]). I think there is an iterative algorithm for solving systems of full rank.
Joe Riel has this for Emacs: http://www.k-online.com/~joer/maplev/maplev.html
There is no way to make a progress bar like how you want, because Maple's output method is designed around printing lines of text or entire expressions at once. What I have found useful is to have an inner loop print different characters (- and + work well) for different types of things that can happen, and have an outer loop break the lines. You can do this using printf("-"); to print the characters and printf("\n"); to break a line. This works especially well for double loops containing an if statement. Another possibility is to print some sort of count and add indents for recursions.
We lost some of your code, due to the fact that html interprets < and > as tags and nukes anything in between. One way to get around that is to select "plain text" as the input format when you post your comment. Can you please post your procedure again ?
It's worth pointing out that your problem may have no solution, unless 1 is an eigenvalue of M. In that case the solution v is the corresponding eigenvector. You can compute eigenvalues and eigenvectors using commands in the LinearAlgebra package. Type with(LinearAlgebra); to load the package, and ?Eigenvalues to see help on the Eigenvalues command. For background information, consult any textbook on linear algebra. A number of free textbooks are available online, such as this one.
This is not an easy problem, to be sure. Your best bet is to try to express the function as a piecewise function. Maple might be able to do this for you, ie: convert(foo, piecewise), I'm not sure. In any case, how you proceed will depend strongly on what the "patches" are. You should try the Optimization package (added in Maple 9.5, improved in Maple 10).
If the equations are all polynomials, do the following:
kernelopts(opaquemodules=false); # access internal commands
eqns := {x1 = f1(theta1, theta2), x2 = f2(theta1, theta2), ...}:  # set of equations
X := indets(map(lhs, eqns));  # should be {x1,x2,...}
U := indets(map(rhs, eqns));  # should be {theta1, theta2}
with(PolynomialIdeals):
J := < map(lhs-rhs, eqns) > ;  # construct an ideal
V := [PolynomialIdeals:-SuggestVariableOrder(J, X union U)];
X := select(member, V, X);  # order the variables optimally
U := select(member, V, U);
infolevel[':-GroebnerBasis'] := 4:  # monitor computation
PolynomialIdeals:-GroebnerBasis(J, lexdeg(X,U), method='bb'):  # precompute an easy GB
K := EliminationIdeal(J, {op(X)});  # use Groebner Walk to eliminate U and keep X
result := Generators(K);
I apologize - it's a little overcomplicated - but given the structure of your equations it should be the fastest possible way. If the result is {0} then theta1 and theta2 can't be eliminated from the polynomials. If the result is {1} then your original equations had no solution.
Maple can do it, provided your non-commutative relations have the following form: D[i]*x[j] = sigma[i](x[j])*D[i] + delta[i](x[j]) where delta[i](p*q) = sigma[i](p)*delta[i](q) + delta[i](p)*q. This covers many common cases, such as differential algebras and various shift algebras. See the help page for Ore_algebra for details. Maple can not handle arbitrary non-commutative relations between the variables, but such computations usually aren't feasible anyway. If you need that, try the program Bergman (http://servus.math.su.se/bergman/). Otherwise, let me know if you need a hand getting Ore_algebra and Groebner working for you. There is a non-commutative example on the help page ?Groebner,Basis_details.
You aren't doing anything wrong. Apple broke most Java applications in OS X 10.3.9 with a Quicktime update six months ago. It caused a big uproar so they released an uninstaller. The issue still exists in Quicktime 7.1, but this time there is no uninstaller because it was a big security update. So as unbelievable as it seems, OS X 10.3.9 is broken (apps don't run!). The Apple discussion boards are full of people who had to hack their systems, reinstall 10.3.9, or upgrade to 10.4 to get their programs to run again. Apple shows no intention of fixing it. Maplesoft however wrote a new installer for Maple 10.04 which works on an updated 10.3.9 system. You will have to contact Maplesoft support and download Maple 10.04. As a 10.3.9 user myself, I really appreciated that they went to this extra effort to support their customers on a broken platform.
Mostly out of curiousity, how large are your linear systems and how many vectors are in the right hand side ?
First 13 14 15 16 17 18 19 Page 15 of 19