Related

while

y:1;

while (y<5) do y...

y;

Calculate

while

y:1;

while (y<5) do y...

y: y*2;

Calculate

while

for a:0.01 while (a &...

Calculate

while

y:1;

while (y<5) do y...

Calculate

? while;

Calculate

while

y:1;

while (y<5) do y...

y;

Calculate

while

y:1;

while (y<5) do y...

y: y*2;

Calculate

while

for a:0.01 while (a &...

Calculate

while

y:1;

while (y<5) do y...

Calculate

? while;

Calculate

while

Run Example
```(%i1)numer:true;
(%o1)                                true
(%i2) ln(x):=log(x)/log(%e);
log(x)
(%o2)                          ln(x) := -------
log(%e)
(%i3) redondeo(num,decimales):=block(       [a:0],   a:round(num*10^decimales)*10^-decimales,    return(a));
(%o3) redondeo(num, decimales) := block([a : 0],
decimales    - decimales
a : 'round(num 10         ) 10           , return(a))
(%i4) biseccion(a,b,expo,N):=block(       [indice:0,bool:true,fa,fp,fb,fafp,TOL,p,er,tabla:matrix(['N,'a,'b,'p,'f('a),'f('b),'f('p),'f('a)*'f('p),'error])],      fa:f(a),   fa:redondeo(fa,expo+2),   TOL:(10)^(-expo),   for i:1 step 1 while (i<
=N and bool=true) do   (      indice:i,      p:((a+b)/2),         p:redondeo(p,expo+2),      fp:f(p),         fp:redondeo(fp,expo+2),      fb:f(b),         fb:redondeo(fb,expo+2),      er:((b-a)/2),         er:redondeo(er,expo+2),      fafp:redondeo(fa*fp,expo+2),            if ( (fa<
0 and fb<
0) or (fa>
0 and fb>
0) ) then      (	           print("No hay cambio de signo"),	 bool:false      ),      tabla:addrow(tabla,[i,a,b,p,fa,fb,fp,fafp,er]),            if ((fp=0) or (er <
TOL)) then      (         print("tolerancia cumplida"),	 bool:false      )      elseif (fafp>
0) then      (         a:p,         fa:fp      )      else      (         b:p      )   ),      if (indice=N) then    (      print(concat("Parametro N=",N," se cumplio. Hay cambios de signo f(a) f(b)")),      print("en las iteraciones hechas.")   ),   display(indice,N),   return(tabla));
(%o4) biseccion(a, b, expo, N) := block([indice : 0, bool : true, fa, fp, fb,
fafp, TOL, p, er, tabla : matrix(['N, 'a, 'b, 'p, 'f('a), 'f('b), 'f('p),
'f('a) 'f('p), 'error])], fa : f(a), fa : redondeo(fa, expo + 2),
- expo
TOL : 10      , for i while (i <= N) and (bool = true)
a + b
do (indice : i, p : -----, p : redondeo(p, expo + 2), fp : f(p),
2
fp : redondeo(fp, expo + 2), fb : f(b), fb : redondeo(fb, expo + 2),
b - a
er : -----, er : redondeo(er, expo + 2), fafp : redondeo(fa fp, expo + 2),
2
if ((fa < 0) and (fb < 0)) or ((fa > 0) and (fb > 0))
then (print("No hay cambio de signo"), bool : false),
tabla : addrow(tabla, [i, a, b, p, fa, fb, fp, fafp, er]),
if (fp = 0) or (er < TOL) then (print("tolerancia cumplida"), bool : false)
elseif fafp > 0 then (a : p, fa : fp) else b : p),
if indice = N then (print(concat("Parametro N=", N,
" se cumplio. Hay cambios de signo f(a) f(b)")),
print("en las iteraciones hechas.")), display(indice, N), return(tabla))
(%i5) f(x):=x-2^-x;
- x
(%o5)                          f(x) := x - 2
(%i6) biseccion(0,1,3,3);
Parametro N=3 se cumplio. Hay cambios de signo f(a) f(b)
en las iteraciones hechas.
indice = 3

N = 3

[ N   a    b      p      f(a)      f(b)     f(p)     f(a) f(p)  error ]
[                                                                     ]
[ 1   0    1     0.5     - 1.0     0.5    - 0.20711   0.20711    0.5  ]
(%o6) [                                                                     ]
[ 2  0.5   1    0.75   - 0.20711   0.5     0.1554    - 0.03218  0.25  ]
[                                                                     ]
[ 3  0.5  0.75  0.625  - 0.20711  0.1554  - 0.02342   0.00485   0.125 ]
(%i7) ```
Run Example
```base(n,d):=block([q:0, r:n, obase:d], while((n>
=d)) do (q:q+1, r:r-d, concat(q,r)));
(%o1) base(n, d) := block([q : 0, r : n, obase : d],
while n >= d do (q : q + 1, r : r - d, concat(q, r)))
(%i2) ```
Run Example
```numer : true;
(%o1)                                true
(%i2) f(x):= cos(x) + %e^(-x);
- x
(%o2)                       f(x) := cos(x) + %e
(%i3) a:1.5;
(%o3)                                 1.5
(%i4) b:2;
(%o4)                                  2
(%i5) tol: 10^(-1);
(%o5)                                 0.1
(%i6) M:matrix(["pm", "f(pm)", "err rel"]);
(%o6)                       [ pm  f(pm)  err rel ]
(%i7) if f(a) * f(b) <
0 then    err: abs(b-a)/(b);
(%o7)                                0.25
(%i8) pm : (a+b)/2;
(%o8)                                1.75
(%i9) while(err>
tol) do(pm : (a+b)/2,M:addrow(M, [pm,f(pm),err]),if f(a) * f(pm)  <
0  then b: pm  else a: pm, err: abs(b-a)/(b));
(%o9)                                done
(%i10) M;
[  pm           f(pm)              err rel      ]
[                                               ]
(%o10)         [ 1.75   - 0.0044721121990469        0.25       ]
[                                               ]
[ 1.625    0.14273454017726    0.14285714285714 ]
(%i11) ```

Help for While