Wrong answer from DSolve when solving a differential equation

As noted by other users, this is a bug in DSolve in Version 12.0.

The problem appears to be related to a change in Series between Version 11.3 and Version 12.0, which is under investigation.

A partial workaround for the problem is to set an assumption on the independent variable as shown below to obtain the correct solution.

In[1]:= DSolve[{y'[x] == y[x]^2 + x^2 - 1, y[0] == 1}, y[x], x, 
  Assumptions -> x > 0] // InputForm

Out[1]//InputForm=
{{y[x] -> (I*2^(I/2)*x*Gamma[1/4 - I/4]*Gamma[1/4 + I/4]*Gamma[3/4 + I/4]*
      ParabolicCylinderD[-1/2 - I/2, (-1 + I)*x] + (1 - I)*2^(1/2 + I/2)*x*Gamma[1/4 + I/4]*
      Gamma[3/4 - I/4]*Gamma[3/4 + I/4]*ParabolicCylinderD[-1/2 - I/2, (-1 + I)*x] + 
     I*x*Gamma[1/4 - I/4]*Gamma[1/4 + I/4]*Gamma[3/4 - I/4]*ParabolicCylinderD[-1/2 + I/2, 
       (1 + I)*x] + (1 + I)*Sqrt[2]*x*Gamma[1/4 - I/4]*Gamma[3/4 - I/4]*Gamma[3/4 + I/4]*
      ParabolicCylinderD[-1/2 + I/2, (1 + I)*x] - (1 - I)*2^(I/2)*Gamma[1/4 - I/4]*
      Gamma[1/4 + I/4]*Gamma[3/4 + I/4]*ParabolicCylinderD[1/2 - I/2, (-1 + I)*x] + 
     2^(3/2 + I/2)*Gamma[1/4 + I/4]*Gamma[3/4 - I/4]*Gamma[3/4 + I/4]*
      ParabolicCylinderD[1/2 - I/2, (-1 + I)*x] - (1 + I)*Gamma[1/4 - I/4]*Gamma[1/4 + I/4]*
      Gamma[3/4 - I/4]*ParabolicCylinderD[1/2 + I/2, (1 + I)*x] - 
     2*Sqrt[2]*Gamma[1/4 - I/4]*Gamma[3/4 - I/4]*Gamma[3/4 + I/4]*
      ParabolicCylinderD[1/2 + I/2, (1 + I)*x])/
    (2^(I/2)*Gamma[1/4 - I/4]*Gamma[1/4 + I/4]*Gamma[3/4 + I/4]*
      ParabolicCylinderD[-1/2 - I/2, (-1 + I)*x] - (1 + I)*2^(1/2 + I/2)*Gamma[1/4 + I/4]*
      Gamma[3/4 - I/4]*Gamma[3/4 + I/4]*ParabolicCylinderD[-1/2 - I/2, (-1 + I)*x] - 
     Gamma[1/4 - I/4]*Gamma[1/4 + I/4]*Gamma[3/4 - I/4]*ParabolicCylinderD[-1/2 + I/2, 
       (1 + I)*x] - (1 - I)*Sqrt[2]*Gamma[1/4 - I/4]*Gamma[3/4 - I/4]*Gamma[3/4 + I/4]*
      ParabolicCylinderD[-1/2 + I/2, (1 + I)*x])}}

I apologize for the confusion caused by this issue.

Devendra Kapadia, Wolfram Research, Inc.


Here's a workaround for this particular case, based on the method shown in Riccati Equation:

Block[{DSolve`DSolveFirstOrderODEDump`Riccati},
 DSolve`DSolveFirstOrderODEDump`Riccati[y_[x_], q0_, q1_, q2_, c_] :=
  Module[{R, S, u},
   S = q2*q0;
   R = q1 + D[q2, x]/q2;
   {{y[x] -> -u'[x]/(q2*u[x]) /. 
       First@DSolve[u''[x] - R*u'[x] + S*u[x] == 0, u, x] /. {C[2] -> 
        C[1] c, C[1] -> c}}}
   ];
 sol = DSolve[ivp = {y'[x] == y[x]^2 + x^2 - 1, y[0] == 1}, y, x]
 ]

Mathematica graphics

ivp /. sol // FullSimplify
(*  {{True, True}}  *)

This seems to be fixed in 12.1.1, DSolve and DSolveValue give the same result as in the workarounds posted:

screenshot of notebook