| Author |
Comment/Response |
Thibault
|
02/05/13 04:33am
My problem is that I need to create a list (in my case the list is TauxZC) but to find the new element of the list I need to solve an equation (which use the first element of the list TauxZC) and then to add the result to my list TauxZC. Is it possible to use a loop ? I tried with Do but it doesn't work.
TauxCA = {0.58`,0.71`, 1.1`, 1.38`, 2.04`, 2.47`,2.94`, 3.26`, 3.49`, 3.68`, 3.85`, 3.99`};
TauxZC = {0.5583333333333332`, 0.58`};
Do[i;solutionréel = {};Solve[100 ==Sum{TauxCA[[i]]*100/(1+TauxZC[[i]])^i+(100+100*TauxCA[[Length[TauxZC]+1]])/(1+x)^(Length[TauxZC]+1),{i,1,Length[TauxCA]}},x];
x /. %;
solution = %; Do[If[solution[[i]] ∈ Reals,
AppendTo[solutionréel, solution[[i]]]], {i, 1, Length[solution]}]
Do[If[solutionréel[[i]] > 0 , AppendTo[TauxZC,
solutionréel[[i]]]], {i, 1, Length[solutionréel]}]; TauxZC = \
Sort[TauxZC], {i, 1, Length[TauxCA] - 2}]
TauxZC
I obtain
ReplaceAll::reps: {0.558333, 0.58} is neither a list of replacement rules nor \
a valid dispatch table, and so cannot be used for replacing.
General::stop: Further output of ReplaceAll::reps will be suppressed during \
this calculation.
Part::partw: Part 13 of {0.58, 0.71, 1.1, 1.38, 2.04, 2.47, 2.94, 3.26, 3.49, \
3.68, <<2>>]} does not exist
Part::partw: Part 13 of {0.5800000000000000, 0.7100000000000000, \
<<47>>, <<48>>,
<<48>>, <<48>>,<<48>>, <<48>>, <<48>>, 3.680000000000000, <<2>>} does not exist.
General::stop: Further output of Part::partw will be suppressed during \
this calculation.
{0.558333, 0.558333, 0.558333, 0.558333, 0.558333, 0.558333, 0.558333, \
0.558333, 0.558333, 0.58, 0.58, 0.58, 0.58, 0.58, 0.58, 0.58, 0.58, 0.58}
But If I write just this without the Do it's work.
TauxCA = {0.58`,0.71`, 1.1`, 1.38`, 2.04`, 2.47`,2.94`, 3.26`, 3.49`, 3.68`, 3.85`, 3.99`};
TauxZC = {0.5583333333333332`, 0.58`};
solutionréel = {};
Solve[100 ==Sum{TauxCA[[i]]*100/(1+TauxZC[[i]])^i+(100+100*TauxCA[[Length[TauxZC]+1]])/(1+x)^(Length[TauxZC]+1),{i,1,Length[TauxCA]}},x];
x /. %;
solution = %;
Do[If[solution[[i]] ∈ Reals,AppendTo[solutionréel, solution[[i]]]], {i, 1, Length[solution]}];
Do[If[solutionréel[[i]] > 0 , AppendTo[TauxZC,
solutionréel[[i]]]], {i, 1, Length[solutionréel]}]; TauxZC = \
Sort[TauxZC];
TauxZC
I also tried with Label and Goto but after 30 minutes I abort the evaluation. (I have less than ten value to find)
If someone can help me, I use mathematica 5.2 and I hope all is understable.
Thanks for your answers
URL: , |
|