2
$\begingroup$

How can I create a list of the following numbers in a table automatically?

list={3 π/10, 7 π/10, 13 π/10, 17 π/10, 23 π/10, 27 π/10, 33π/10, 37π/10,....}

I wanted to use (4n-1)π/10, but it doesn't make sense. The interval between numbers is:

(4, 6, 4, 6, ....)*π/10

Also, we can see the period which has the behavior as:

From 0 to π

[0, π],,(4n-1)π/10

and

[π, 2π],, (4n+1)π/10

etc.

$\endgroup$
8
  • $\begingroup$ What is the list? It makes no sense as is, it is not a proper list, nor list of list, nor... $\endgroup$ – ciao Oct 8 '15 at 7:03
  • 1
    $\begingroup$ Why does the pattern change between 27 and 30? The next element for the pattern would be 33 $\endgroup$ – Jason B. Oct 8 '15 at 7:19
  • $\begingroup$ So Sorry, I made a mistake I just have corrected. I do apologize for my last mistake. You are right $\endgroup$ – Unbelievable Oct 8 '15 at 7:21
  • $\begingroup$ "If you don't like to think"? Is FindSequenceFunction only for the non-thinkers? lol $\endgroup$ – Jason B. Oct 8 '15 at 7:27
  • $\begingroup$ O, my god, Mathematica is so powerful and wonderful. $\endgroup$ – Unbelievable Oct 8 '15 at 7:30
3
$\begingroup$

Yet anoteher way:

Table[((Mod[n + 1, 2]*4 + 3)/10 + Floor[(n - 1)/2]) π, {n, 1, 10}]
$\endgroup$
5
$\begingroup$

Another, simple way:

Riffle[#, # + 4 Pi/10] &@ Table[(3+i) Pi/10, {i, 0, 30, 10} ]
$\endgroup$
5
$\begingroup$
π(Accumulate[Flatten[ConstantArray[{6, 4}, 10]]] - 3)/10
$\endgroup$
3
$\begingroup$

This will do the trick, don't know if it's the simplest, but I only recently discovered Reap and Sow so I use them all the time now

list = Reap[
        iter = 3*(Pi/10); 
        Do[Sow[iter]; 
           iter += If[OddQ[n], 4, 6]*(Pi/10);  
        , {n, 10}]][[2,1]]

(*
{(3 π)/10, (7 π)/10, (13 π)/10, (17 π)/10, (23 π)/10, (27 π)/10, (33 π)/10, (37 π)/10, (43 π)/10, (47 π)/10}
*)

Or, following Kuba's suggestion

func = FindSequenceFunction[{(3 π)/10, (7 π)/10, (13 π)/10, (17 π)/10, (23 π)/10, 27 π/10}];

(*
-(1/20) \[Pi] ((-1)^#1 + 5 (-1)^(2 #1) - 10 #1) &
*)

Table[func[x], {x, 1, 10}]

gives the same

$\endgroup$
0
2
$\begingroup$

Just for fun:

Internal`InheritedBlock[{Table}, SetAttributes[Table, SequenceHold]; 
 Table[Sequence[3 π/10 + i π, 7 π/10 + i π], {i, 0, 5}]]
 (* {(3 π)/10, (7 π)/10, (13 π)/10, (17 π)/10, 
     (23 π)/10, (27 π)/10, (33 π)/10, (37 π)/10,
     (43 π)/10, (47 π)/10, (53 π)/10, (57 π)/10} *)
$\endgroup$
1
$\begingroup$
f[n_] := π/10 Range[3, 10 n + 3, 10]~List~Range[7, 10 n + 7, 10] // Transpose // Flatten
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.