1
$\begingroup$

I have obtained a numerical solution using NDSolve for two functions a(x) and b(x). how do I use Table to make a list of a(x) vs b(x) values. is it simply Table[{a(x),b(x)},{x,0,100}] or should I use something else since a(x) and b(x) are not analytic? the following is part of my code(a(x) and b(x) is f(z) and phi(z)):

sol = NDSolve[{-((
   f[z] ϵ[
     z] (2 - 2 ϵ[z] + (1 + z) Derivative[1][ϕ][
        z]))/(1 + z)^2) + 
  Derivative[1][f][
    z] ((-12 + 12 ϵ[z]^2 + 
       4 (1 + z) Derivative[1][ϵ][z] - 
       4 Derivative[1][ϕ][z] - 
       4 z Derivative[1][ϕ][z] - 
       6 (1 + z) ϵ[z] Derivative[1][ϕ][z] + 
       Derivative[1][ϕ][z]^2 + 
       2 z Derivative[1][ϕ][z]^2 + 
       z^2 Derivative[1][ϕ][z]^2)/(2 (1 + z) (2 - 
         2 ϵ[z] + (1 + z) Derivative[1][ϕ][z]))) + (
   f^′′)[z] == (
  c^2 (3 (1 + z) ϕ'[z] + 6 (1 - ϵ[z])))/(1 + z)*
  H[z]^2*D[(8*Pi*G* ρ[z])/(3*Subscript[a, 0]^2*(H[z])^2), 
   z], (1 + z)^2*ϕ''[
    z] - (2 - ϵ[z])*(1 + z) ϕ'[z] == 
 6 (1 - ϵ[z]), ϕ[zi] == 0, ϕ'[zi] == 0, 
f[zi] == (5 c^2)/Subscript[a, 0]^2 H0^2 (1 + zi), 
f'[zi] == 0}, {f[z], ϕ[z], ϕ'[z]}, {z, 0, zi}];

ParametricPlot[Evaluate[{ϕ'[z], f[z]} /. sol], {z, 0, 10000}]
$\endgroup$

closed as off-topic by bbgodfrey, MarcoB, user9660, m_goldberg, Öskå May 22 '16 at 20:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – bbgodfrey, MarcoB, Community, m_goldberg, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ What happens when you use Table[{a(x),b(x)},{x,0,100}] ? $\endgroup$ – Sumit May 20 '16 at 21:31
  • $\begingroup$ Can you please provide a minimal working example of you NDSolve code? It doesn't need to include all the bells and whistle of your actual code, but it is necessary in order to see how you are storing the functions a and b, especially since you are using syntax that doesn't work in Mathematica (functions are defined using square brackets, not parentheses). $\endgroup$ – march May 20 '16 at 21:49
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 May 20 '16 at 22:03
  • $\begingroup$ You have two ODEs and five unknown functions, so NDSolve cannot provide an answer. You also have undefined constants. Finally, ` ( f^[Prime][Prime])[z]` should be f''[z]. $\endgroup$ – bbgodfrey May 21 '16 at 1:51
  • $\begingroup$ Fix the mentioned problems and then Table[{f[z], φ[z]} /. sol[[1]], {z, 0, 100}] $\endgroup$ – Bill May 21 '16 at 2:08
1
$\begingroup$

I Have finally found what was causing the problem. it was with notation. I define my constant a_o but in the equation I have used a_0. Once I changed that it was working.

$\endgroup$

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