Group Abstract Group Abstract

Message Boards Message Boards

[Solved] Storing solutions of systems of equations in a loop

6 Replies
Posted 4 years ago

Edit:

What I would try is

conds={};
eqns1={
pd+cd (-2+1/(2+((1+lambda^(3/4))2 pf*2)/pd*2))==0,
10 pf==27/2+(9 pd*2)/((2+8 lambda*3/4+4 lambda*3/2) pd*2+4 (1+lambda^(3/4))4 pf*2),
4/3 (1+lambda^(3/4))3 lambda*1/4==(10 (-cd+pd))/(pd*3 (1/pd^2+1/((1+lambda^(3/4))^2 pf^2))3/2 pf*2)
};
eqns2={
pd+cd (-2+1/(2+((1+lambda^(3/4))2 pf*2)/pd*2))==0,
5 pf==6+1/(1/2+2 lambda*3/4+lambda*3/2+((1+lambda^(3/4))4 pf*2)/pd*2),
4/3 (1+lambda^(3/4))3 lambda*1/4==(10 (-cd+pd))/(pd*3 (1/pd^2+1/((1+lambda^(3/4))^2 pf^2))3/2 pf*2)
};
matrix=Reap[
For[cd=0,cd<1/2,cd+=0.1,
 sol1=FullSimplify[NSolve[Join[eqns1,conds],{pd,pf,lambda}]];
 sol2=FullSimplify[NSolve[Join[eqns2,conds],{pd,pf,lambda}]];
 Sow[{cd,lambda/.sol1[[1]],lambda/.sol2[[1]]}]
]][[2,1]]

which intends to create a matrix of three columns, cd, lambda from 1 and lambda from 2.

But when I run that I don't get any solutions for lambda in any of those.

POSTED BY: Bill Nelson
Posted 4 years ago
POSTED BY: Updating Name
Posted 4 years ago

Please, for cd==0 manually show the matrice you want. Repeat that for cd==1/10. Maybe from that I can understand what it is you want in what form and where you want it stored. Thank you

Or you might think of using Table instead of For. Table can store the result of your calculations with each iteration and give you all those when it is finished.

POSTED BY: Bill Nelson

Ah! I am very sorry about that! I corrected the code. Now your code is running and I find the solution but I don't see where the matrice is stored? Mathematica apparently only remembers the last value of lambda and cd...

Posted 4 years ago
POSTED BY: Bill Nelson

Thank you for your answer. You don't find any solutions because it should be eqns1=... and eqns2=... without capital letters. Sorry, my message got auto corrected, I just edited my post.

I have tried your way and I have two errors when solving: ReplaceAll::reps and General::stop. Any idea why?

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