Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I have a couple of questions about the problem I am trying to solve

n = 7;
alpha = 0.01; c = 10;

atable = Table[a[i], {i, 0, n}]; 
Solu = y^Range[0, n].atable;

Leftequ = Solu; 
Rightequ =  A y^2 +  B y + DD + 1/2/alpha Integrate[Solu^2, y];

Lec = CoefficientList[Leftequ, y];
Rec = CoefficientList[Rightequ, y];

Lec = PadRight[Lec, Min[Length[Lec], Length[Rec]]];
Rec = PadRight[Rec, Min[Length[Lec], Length[Rec]]];

eqs = Lec == Rec;

Sol = Solve[eqs, atable]

If I check a[0] it will show that a[0]=a[0], but I want to set it to a[0] = DD. This is probably a mistake I overlooked, but nevertheless could not find it. Thanks in advance.

share|improve this question

marked as duplicate by m_goldberg, Yves Klett, bobthechemist, Mr.Wizard Feb 5 at 16:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
This answer might should be helpful: Using the result of functions that return replacement rules. –  Yves Klett Feb 5 at 14:16
    
Possible duplicates: (3175), (6669), (9035). –  Mr.Wizard Feb 5 at 14:20

1 Answer 1

The result you see is a list of replacement rules (check documentation). If you want to pull a specific value out do something like this...

a[0] /. Sol[[1]]

which in this case will give you DD.

Solve will not assign the value DD to a[0], the replacement rules tell you what they're value is in the solution. If mathematica did assign values to a[0], a[1]... etc when you ran solve the second time you run it everything would break because a[0] wouldn't be a free variable it would be DD.

Note: generally best to use lower-case starting names, sol rather than Sol, rec rather than Rec as all Mathematica's own symbols start with Capital letters and eventually you'll hit one and get an error.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.