0
$\begingroup$

Is there any way to copy a number from an error message and assign it to a variable, without manually doing it?

For instance, I am trying to solve some coupled Differential equations as follows:

H[a_] := Sqrt[1/(3 10^18) (B[a] 10^(-3 a) + R[a] 10^(-4 a) )] ;
eqn1 = M'[a] + 1/H[a] (1/M[a])^2;
eqn2 = R'[a] + 10^a/M[a] M'[a] B[a];
eqn3 = B'[a] - 1/M[a] M'[a] B[a];
sol1 = NDSolve[{eqn1 == 0, eqn2 == 0, eqn3 == 0, M[0] == 100, 
   R[0] == 10^50, B[0] == 10^47}, {M, R, B}, {a, 0, 15}]

I am getting an error message (although the equations are getting solved upto a~13.5) as :

NDSolve::ndsz: At a == 13.536140129488167`, step size is effectively zero; singularity or stiff system suspected.

I want to extract the number 13.536140129488167 from the error message and assign it to variable, without manually copying and pasting it.

I need to do this since I have to run the code in some loop or vary some other parameters.

$\endgroup$
5