# Obtaining the other axis value

I'm new at coding and I got this simple differential equiation and the plot of this function involved, I can obtain the value of the dependant variable based on the independant varible as usual, what I want to do now is to find a new value of the independant variable giving it the dependant variable based on the ploted graph, in other words I want to find y for a given x from the graph. this is my short code. Only half of it works.

Sol = NDSolve[{a'[t] == Sqrt[a[t]], a == 3}, a, {t, 0, 180}]
graph = Plot[a[t] /. Sol, {t, 0, 180}]
FindRoot[a[t] == 0.44 /. graph, {t, 0}] (*this is the part that doesn't work*)
a[t] /. Sol /. t -> 180


Any kind of help would be hugely appreciated. Thanks c:

• Could you provide a definition? Feb 24 at 6:37
• How so? what do you mean?
– Sosa
Feb 24 at 6:46
• Sorry, it was my misunderstanding, you can't use /. graph, replace graph with Sol, you will get {t -> -0.0163865} which is out of bound and a[-0.0163865] /. Sol is around {2.98117}, technically you'd find a local minimum not the exact answer you're looking for. Feb 24 at 7:27

Another way is use WhenEvent and Reap and Sow.(Also need to replace 0.44 to another number such as 10).

{{sol}, {pts}} =
NDSolve[{a'[t] == Sqrt[a[t]], a == 3,
WhenEvent[a[t] == 10, {Sow[t]}]}, a, {t, 0, 180}] // Reap
Plot[a[t] /. First@sol // Evaluate, {t, 0, 10},
Epilog -> {PointSize[Large], Red,
Point[({#, a[#]} /. sol) & /@ pts]}]


{{2.86045}} Appendix

The questioner's original approach.

sol = NDSolve[{a'[t] == Sqrt[a[t]], a == 3}, a, {t, 0, 180}]
graph = Plot[a[t] /. sol, {t, 0, 180}]
FindRoot[a[t] == 10 /. sol, {t,
0}] (*this is the part that doesn't work*)
a[t] /. sol /. %


{t -> 2.86045}

{10.}

• i just want to read the graphic at another value i.e.30 in the Y axis what is in the X axis, from that same graph
– Sosa
Feb 24 at 18:11
• {a'[t] == (0.16 - 0.0622 Sqrt[a[t]])/(Pi (a[t])^2), a == 0.5} in this equation in it's graph, if i give it a value of 3 in the Y axis what it's the value on the X axis?
– Sosa
Feb 24 at 18:15
• @Sosa {{sol}, {pts}} = NDSolve[{a'[t] == (0.16 - 0.0622 Sqrt[a[t]])/(Pi (a[t])^2), a == 0.5, WhenEvent[a[t] == 2.3, {Sow[t]}]}, a, {t, 0, 180}] // Reap Plot[a[t] /. First@sol // Evaluate, {t, 0, 180}, Epilog -> {PointSize[Large], Red, Point[({#, a[#]} /. sol) & /@ pts]}] Feb 24 at 22:58

First, you should not use variable names with capital letters, those are used by the system. I corrected your syntax. Here is the working code. Note that the FindRoot gives warnings because the specified value is out of bounds:

sol[t_] =
a[t] /. NDSolve[{a'[t] == Sqrt[a[t]], a == 3}, a, {t, 0, 180}][]
graph = Plot[sol[t], {t, 0, 180}]
FindRoot[sol[t] == 0.4, {t, 0}]
sol

• Thanks for the tip, I would take that in count
– Sosa
Feb 24 at 19:02