MathGroup Archive 2010

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

Search the Archive

Re: For loop outputs to a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112948] Re: For loop outputs to a list
  • From: Peter Pein <petsie at dordos.net>
  • Date: Thu, 7 Oct 2010 03:37:03 -0400 (EDT)
  • References: <i8c90m$gd8$1@smc.vnet.net>

Am Mon, 4 Oct 2010 10:07:18 +0000 (UTC)
schrieb matthew <mattypang at gmail.com>:

> Hello, I'm a bit rubbish at mathematica and I've tried searching this
> group for help.
> 
> For[i = 0, i < 10^6, i++,
>   If[Abs[Re[LS2[0.004 + i*Pre]] - Re[RS[0.004 + i*Pre]]] < 10^-7  ,
>    Print[N[0.004 + i*Pre]]
>     If[0.004 + i*Pre > 0.007, Break[]]
>    ]];
> 
> which gives me an output of:
> 0.00424538
> 
> 0.00448576
> 
> 0.00514995
> 
> 0.00584308
> 
> 0.00584309
> 
> 0.00646176
> 
> 0.00758337
> 
> How would I get these into a list or some way i can manipulate it?
> 

Hi,

as the Break depends only on i and the constant Pre, it is easy to use
Select:

Select[.004 + Pre Range[Ceiling[3/(1000 Pre)]],
 Abs[Re[LS2[#]] - Re[RS[#]]] < 10^-7 &]

Peter



  • Prev by Date: Re: change the base of the Log[] used by LogLogPlot?
  • Next by Date: Re: Function argument types
  • Previous by thread: Re: For loop outputs to a list
  • Next by thread: Plotting a function dynamically in a loop