# How can I solve this differential equation for some restricted domain and plot the solution for some values of the parameter

I have encountered some problems when solving this DE. I am wondering if anyone could help me point out the mistakes.

The question says:

Obtain and verify a symbolic solution for $y'(x)+xy(x)^2=a, y(0)=0$ for $x\ge0$ and a generic real parameter $a$. Plot solutions for $a>0$.

My code:

sol = DSolve[{y'[x] + x (y[x])^2 == a, y[0] == 0}, y, x]


The output contains some expression with AiryAi and AiryAiPrime functions. Then I tried to verify the solution by substituting it to the RHS of the DE. But instead of getting $a$, I get an even longer and more complicated expression with AiryAi and AiryAiPrime functions.

Here is how my code looks like for the substitution:

y'[x] + x (y[x])^2 /. sol[[1]]


I don't quite understand why it does not give $a$ as a result.

My next question is, how can I solve for $x\ge0$ in particular? I tried to include $x\ge0$ as follows:

DSolve[{y'[x] + x (y[x])^2 == a, y[0] == 0, x>=0}, y, x]


I know this is ridiculous thing to do, the error message says it is not an equation. Then how can I solve only for $x\ge0$? I tried to use the and expression, but it doesn't seem to work inside the DSolve command.

Also, my last concern is about plotting the solutions for $a>0$. I tried to use the standard Plot command, but I can only include y as a function of x such as

Plot[y, {x, xmin, xmax}]


How can I include the restriction for $a>0$?

I believe this shouldn't be a hard problem, or I might have overlooked some trivial things, but due to my poor Mathematica skills, I have spent a long time figuring this out.

If anyone could help me out on this, I will be really appreciative and grateful!
After doing sol[a_, x_] = y[x] /. First @ DSolve[{y'[x] + x (y[x])^2 == a, y[0] == 0}, y, x], look at Plot3D[sol[a, x], {x, 0, 3}, {a, 0, 3}]. –  Ｊ. Ｍ. Jun 5 at 2:49
You should already know what /. is, seeing that you've used it yourself; if not, highlight /. in your notebook and press the F1 key. First @ x is "prefix" notation; this is equivalent to First[x]. –  Ｊ. Ｍ. Jun 5 at 2:56
You might be interested in FullSimplify[]; see if it helps you answer your last question. –  Ｊ. Ｍ. Jun 5 at 3:10