I am trying to solve a system of several simultaneous equations that have been generated by a series of modules and functions, using this module:

SolvePhiEqs[number_] :=
Module[{eqs, simeqs, diffsimeqs, Xvalues},

eqs = GeneratePhiEqs[number];

Xvalues = XValues[Range[1, 2*number]];

k = 1;
r = 1;

simeqs = 
   Table[Eq[j] -> Phi[j] == Phi[j + 1] /. eqs /. x -> x[j] /. 
   Xvalues , {j, 2*number}];
diffsimeqs = 
   Table[Eq[j + 2*number] -> xDiffPhi[j] == xDiffPhi[j + 1] /. eqs /. 
   x -> x[j] /. Xvalues, {j, 2*number}];

EquatedEqs = Flatten@{simeqs, diffsimeqs};

Coefficients = 
   Flatten@{Table[R[j], {j, 0, number - 1}], Table[T[j], {j, number}],
   Table[A[j], {j, number}], Table[B[j], {j, number}]};

FinalCoefficient = 
   Solve[Simplify[Reduce[Array[Eq, 4*number] /. EquatedEqs]], 


However after having to solve more than 4 simultaneous equations (what is generated by using a 'number_' argument of 1), my computer starts churning away and does not come back with an answer for at least 10 mins (the longest I've tried so far). As this is supposed to be a general solution to a problem, I am looking at generating solutions up to at least 'number = 20' or so, so this is not particularly encouraging. However, I am fairly sure the code is functional, if not particularly efficient.

Whilst I appreciate that it is not easy to make a specific comment based on incomplete code, if anyone has any more general suggestions as to how to make simultaneous equation solving more efficient, they would be much appreciated!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.