Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.3K Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

Slow code for a large system of equations

I am trying to run my code, but it is taking too much time (hours for only few terms). I am new to Mathematica world so is there any way I can rewrite my code so it will run faster.

Please see the attached file

I really appreciate your help guys. Thank you in advance.

Attachments:
POSTED BY: peter azizi
3 Replies

You have a system of 52 polynomial equations in 28 unknowns, of high degree. The first 26 equations, however, are very easy. You can solve them and replace in the remaining equations:

sol1 = Solve[0 == Union@Eq[[1 ;; 26]]]
remainingFirstStep = Complement[Eq /. First@sol1, {0}]

The first two remaining equations are linear, and you can solve for them and replace in the rest:

sol2 = Solve[remainingFirstStep[[1 ;; 2]] == 0]
remainingSecondStep = 
 Factor[remainingFirstStep[[3 ;; -1]] /. First@sol2]

The fifteenth and the next-to-last of the remaining equations factor into linear polynomials. Solve these equations and replace into the rest:

sol3 = Solve[remainingSecondStep[[{15, -2}]] == 0]
remainingThirdStep = 
 Factor@Map[Complement[#, {0}] &, Factor[remainingSecondStep /. sol3]]

You get two sets of equations. These are easy enough to solve directly:

sol4 = Map[Solve[# == 0] &, remainingThirdStep]

It seems that the only nonzero solution is sol4[[2,1]]:

{a[13] -> -(a[18]/2), a[19] -> a[18]}

You can check this solution by replacing into the original equations:

nonzeroSol = 
 Solve[Flatten[{sol4[[2, 1]], sol3[[2]], sol2, sol1} /. Rule -> Equal]]
Expand[Eq /. nonzeroSol]
POSTED BY: Gianluca Gorni

Thank you Gustavo, do you have idea how can I use Matrix algebra? When I run my code this step

sol = Solve[Eqn, Table[a[i], {i, 1, Length[Eq]}]][[1]]

is taking too much time . As I mentioned before, I am a beginner in Mathematica.

Thank you again.

POSTED BY: peter azizi
Posted 10 years ago

That is a very large set of equations! You might want to try using

w[x_, y_] := Sum (...etc...)

instead of

w[x_, y_] = Sum (...etc...)

Could the problem be rewritten using matrix algebra in order to simplify the calculations? That would speed it up.

POSTED BY: Gustavo Delfino
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard