2
$\begingroup$

I have the following expression:

sol1 = 
  (11 + 3*δ - 11*θ + 4*m*θ - 3*δ*θ - 8*Sqrt[(-(2 + δ))*(-1 + θ)*(1 - θ + m*θ)])/(4 + 4*δ)

I want to plug numbers into $ \theta $ that range from $ 0.1 $ to $ 0.9 $.

Does anybody know how to do this more efficiently than using a loop? I tried to use For and Do, but I am not sure how to implement the procedure I want correctly.

$\endgroup$
  • $\begingroup$ For a one-shot use, ReplaceAll (/.) suffices: e.g., sol1 /. θ -> Range[.1, .9, .1]. If repeated usage is intended, SetDelayed (:=) is more appropriate. $\endgroup$ – Αλέξανδρος Ζεγγ Aug 6 '19 at 6:27
  • $\begingroup$ @ΑλέξανδροςΖεγγ - it is worth pointing out that the reason that ReplaceAll works here is that all of the operations used in sol1 are Listable $\endgroup$ – Bob Hanlon Aug 6 '19 at 18:58
6
$\begingroup$

You can use Table for that and specify the step you want:

Table[sol1, {θ,0.1,0.9,0.1}]
| improve this answer | |
$\endgroup$

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