# How to pass a pair of values to Table function?

I define a function like this:

ϕ[t_,ϕ0_,ϕ1_]:=ϕ0+ϕ1/ArcSin[0.97] ArcSin[0.97 Sin[2Pi f(t-0.25/f)]]/.f->30


which generate:

$$\phi (t)=0.754586 \times \text{\phi 1} \times\sin ^{-1}(0.97 \sin (60 \pi (t-0.00833333)))+\text{\phi 0}$$

Then I want to generate two function with (ϕ0,ϕ1)=(0,10) and (ϕ0,ϕ1)=(100,200) with Table function like bellow:

Table[ϕ[t], {{ϕ0, ϕ1}, {{0, 10}, {100,200}}}]


But it doesn't work.

How to manage it ?

• ϕ[t, ##] & @@@ {{0, 10}, {100, 200}} should work. Is that what you're looking for? If the syntax is unfamiliar, check out Apply and SlotSequence in the docs. – Martin Ender Mar 29 '16 at 15:11
• If you really want to use Table you can "replace one of the @" in Martin's answer: Table[ϕ[t, ##] & @@ pp, {pp, {{0, 10}, {100, 200}}}] – BlacKow Mar 29 '16 at 15:21
• @MartinBüttner Thank you very much. I've learnt a new skill ! – PureLine Mar 30 '16 at 1:53
• @unlikely Frankly speaking, this method seems the same with using Rule. – PureLine Mar 30 '16 at 1:56
• @BlacKow Thanks for sharing. Your method shares something in common with MikeLimaOscar's . – PureLine Mar 30 '16 at 1:58

Changing your initial function definition slightly makes using Table easier and saves having to mess around with SlotSequence, Function, Apply, etc. For example, I would define ϕ as:

ϕ[t_, {ϕ0_, ϕ1_}] := ϕ0 + ϕ1 / ArcSin[0.97] ArcSin[0.97 Sin[2Pi f(t - 0.25 / f)]] /. f -> 30


Such that the parameters are paired in a single argument. Then you can use:

Table[ϕ[t, ϕ01], {ϕ01, {{0, 10}, {100,200}}}]


which I think is "more natural".

Incidentally, the replacement of f occurs every time the function ϕ is evaluated which is inefficient. It would be better to wrap the RHS of your definition in Evaluate.