MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Stuck in a For Loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31044] Re: Stuck in a For Loop
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 6 Oct 2001 03:32:07 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <9p2pdo$30a$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

When  will the test c0 <=c0+0.1
give you False ? with a high precision arithmetic ?

Regards
  Jens


Moranresearch at aol.com wrote:
> 
> I am trying to iterate from c0 -.1 to c0+.1 in steps of 0.001 and from K=-2
> to k= 2 insteps of 0.01
> 
> The code below hangs up. Any suggestions appreciated. Thank you.
> 
> de = {0.221`, 0.45225`, 0.6602777777777777`, 0.8903611111111112`,
>       1.0920277777777778`, 1.3204166666666668`, 1.5235833333333335`,
>       1.7480833333333334`};
> ce = {6.1280277777777785`, 6.129388888888888`, 6.129833333333334`,
>       6.130222222222223`, 6.1306111111111115`, 6.130916666666667`,
>       6.131055555555555`, 6.130972222222223`};
> c0 = ce[[1]];
> MAXERR = 100000; K = 10;
> minErr = MAXERR;
> bestK = STARTK;
> numConvergence = 0;
> For[c0 = c0 - 0.1, c0 <= c0 + 0.1, c0 += 0.001,
>     For[K = -2.0, K <= 2.0, K += 0.01, sum = 0.0; num = 0;
>         c02 = c0*c0;
>         For[j = 0, j < 7, j++,
>           If[(c0 > 0), r = de[j]; c = ce[j];
>             sum += Abs[(Sqrt(c02 - K*r*r) - c)]; num++;]];
>         If[(num <= 0), Continue];
>         err = sum/num;
>         If[(err < minErr), bestc0 = c0; bestK = K; minErr = err;
>           numConvergence++;];];];
> If[(numConvergence == 1), STARTK, bestK]


  • Prev by Date: Re: Frameticks
  • Next by Date: Re: Mathlink help needed
  • Previous by thread: Re: Pasting several cells at once
  • Next by thread: Re: Mathlink help needed