Skip to main content
1 of 2
Nasser
  • 150.5k
  • 12
  • 161
  • 374

I assume you wan to collect the values of c in cList?

Just replace your loop with

cList=First@Last@Reap@While[Abs[b-a]/2>ϵ,
      c=(a+b)/2;
      iter=iter+1;(*number of iterations*)
      Sow[c];
      If[f[a]*f[c]<0,b=c,a=c]
];

Mathematica graphics

Lookup help on Sow and Reap

Btw, iter=iter+1 can be written as iter++ in Mathematica.

Nasser
  • 150.5k
  • 12
  • 161
  • 374