0
$\begingroup$

I integrated this system of two differential equations

b = 0.2001;
k = 8 Pi;
G = 1.5;
Z = 1.1065;
U = 0.478;

s = NDSolve[{Derivative[1][R][t] == (R[t] Sqrt[k \[Rho][t]])/
    Sqrt[3], 
   Derivative[1][\[Rho]][
     t] == -((3 G \[Rho][t] Derivative[1][R][t])/R[t]) + 
     18 Derivative[1][R][t]^2 Z \[Rho][t]^(b + 
       1) (G R[t])/U + 
     3 Derivative[1][R][t] Z \[Rho][
       t]^b(G R[t]^2)/U Derivative[1][\[Rho]][t], 
   R[1000] == 100000, \[Rho][1000] == .000001}, {R, \[Rho]}, {t, 0 , 
   1000}]

Mathematica finds a singular point when the time t=884.8375974007517. I plotted the solutions starting from this time and I fitted them with a power-law function.

Plot[{Evaluate[{R[t]} /. s], 
   25000*(t - 884.8375974007517)^((2 b + 1)/3)}, {t, 
   884.8375974007517, 890}, PlotRange -> All, Frame -> True, 
  FrameLabel -> {Style["t", Medium], Style["R(t)", Medium]}, 
  GridLines -> Automatic, PlotStyle -> {Black, Red}]

Plot[{Evaluate[{\[Rho][t]} /. 
         s], ((2 b + 1)^2/(3 K)) (t - 
           884.8375974007517)^(-2)}, {t, 884.86, 890}, PlotRange -> All, 
      Frame -> True, 
      FrameLabel -> {Style["t", Medium], Style["\[Rho](t)", Medium]}, 
      GridLines -> Automatic, PlotStyle -> {Black, Red}]

This is what I get

enter image description here enter image description here

I would like to make the x-axis starting from t=0 instead of t=884.8375974007517. I think is something related to the plot rather than the integration.

$\endgroup$
  • 1
    $\begingroup$ Plot[{Evaluate[{R[t]} /. s], 25000*(t)^((2 b + 1)/3)}, {t, 0, 6}, PlotRange -> All, Frame -> True, FrameLabel -> {Style["t", Medium], Style["R(t)", Medium]}, GridLines -> Automatic, PlotStyle -> {Black, Red}]? $\endgroup$ – Feyre Nov 24 '16 at 16:01
  • 1
    $\begingroup$ What do you mean by "shift all the x-axis to zero"? Also, please provide s, so that your code can be run by readers. $\endgroup$ – bbgodfrey Nov 24 '16 at 16:01
2
$\begingroup$

You are after FrameTicks:

min = Min@First[s][[1, 2]]["Domain"]

884.838

trans = Table[{min + i, i}, {i, 0, 10}]

{{884.838, 0}, {885.838, 1}, {886.838, 2}, {887.838, 3}, {888.838, 4}, {889.838, 5}, {890.838, 6}, {891.838, 7}, {892.838, 8}, {893.838, 9}, {894.838, 10}}

ticks = {{Automatic, Automatic}, {trans, Automatic}};

Plot[{Evaluate[{R[t]} /. s], 25000*(t - min)^((2 b + 1)/3)}, {t, min, 
  890}, PlotRange -> All, Frame -> True, 
 FrameLabel -> {Style["t-" <> ToString[min], Medium], 
   Style["R(t)", Medium]}, GridLines -> Automatic, 
 PlotStyle -> {Black, Red}, FrameTicks -> ticks]

Plot[{Evaluate[{ρ[t]} /. 
    s], ((2 b + 1)^2/(3 k)) (t - min)^(-2)}, {t, min + 0.02, 890}, 
 PlotRange -> All, Frame -> True, 
 FrameLabel -> {Style["t-" <> ToString[min], Medium], 
   Style["ρ(t)", Medium]}, GridLines -> Automatic, 
 PlotStyle -> {Black, Red}, FrameTicks -> ticks]

enter image description here

enter image description here

|improve this answer|||||
$\endgroup$
  • $\begingroup$ This is not according to the label "t". The x-axis should be labeled "$t-884.838$" instead, shouldn't it? $\endgroup$ – José Antonio Díaz Navas Nov 25 '16 at 19:55

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.