Re: Strategy for overly long computations?
- To: mathgroup at smc.vnet.net
- Subject: [mg35379] Re: Strategy for overly long computations?
- From: "Rasmus Debitsch" <Debitsch at t-online.de>
- Date: Wed, 10 Jul 2002 02:19:49 -0400 (EDT)
- References: <agbfnf$jf1$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hello, while solving the system Mathematica must handle huge terms of symbolic values (x1, y1, ...). Using the two step strategy (eliminate and solve), you can improve the performance by replacing the coefficients of x, y and z in the new equation by new variables. elim=Eliminate[{lgrx,lgry,lgrz},{lm1,lm2}] x2 y1 z-x1 y2 z+x1 yv z-x2 yv z-x2 y z1+x y2 z1-x yv z1+x2 yv z1+x1 y z2- x y1 z2+x yv z2-x1 yv z2-x1 y zv+x2 y zv+x y1 zv-x2 y1 zv-x y2 zv+ x1 y2 zv==xv (y1 z-y2 z-y z1+y2 z1+y z2-y1 z2) elim2=Collect[#,{x,y,z}]&/@(elim\[LeftDoubleBracket]1\[RightDoubleBracket]- elim\[LeftDoubleBracket]2\[RightDoubleBracket]) x2 y1 z-xv (y1-y2) z-x1 y2 z+x1 yv z-x2 yv z-x2 y z1+x y2 z1-x yv z1+x2 yv z1+ x1 y z2-x y1 z2+x yv z2-x1 yv z2-xv y (-z1+z2)-xv (y2 z1-y1 z2)-x1 y zv+ x2 y zv+x y1 zv-x2 y1 zv-x y2 zv+x1 y2 zv coeffs=Internal`DistributedTermsList[elim2,{x,y,z}] {{{{1,0,0}, y2 z1-yv z1-y1 z2+yv z2+y1 zv-y2 zv},{{0,1,0},-x2 z1+xv z1+x1 z2-xv z2- x1 zv+x2 zv},{{0,0,1}, x2 y1-xv y1-x1 y2+xv y2+x1 yv-x2 yv},{{0,0,0},-xv y2 z1+x2 yv z1+ xv y1 z2-x1 yv z2-x2 y1 zv+x1 y2 zv}},{x,y,z}} elim3 = a1 x + a2 y + a3 z + a4 Solve gives a solution then: sol = Solve[{elim3 == 0, cn1, cn2}, {x, y, z}] and you can replace the new symbols: solc = sol /. {a1 -> coeffs[[1, 1, 2]], a2 -> coeffs[[1, 2, 2]], a3 -> coeffs[[1, 3, 2]]], a4 -> coeffs[[1, 4, 2]]} You can try to simplify the solution. But using simplify will take a long time, too. The code below is not faster, but gives some feedback. This can be used for a first estimate of the complete processing time. solx = x /. solc[[]1, 1]]; MapAll[( If[LeafCount[#] > 100, Print["(", LeafCount[#], ") ", Short[#]] ]; sols = Simplify[#]; If[LeafCount[#] > 100, Print[" --> (", LeafCount[sols], ") ", Short[sols]] ]; sols ) &, solx[[]2]] ] I don't think, that the solution is of any use. If no miracle happens during Simplify, the solution will have thousends of term. My suggestion: Use "real" numbers or try to reformulate the problem. -- Rasmus