Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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!
Many thanks in advance!

share|improve this question
1  
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}]. –  J. M. Jun 5 '13 at 2:49
    
@0x4A4D. Thank you for the comment. I don't understand the /. First @ bit. What is it's purpose? Is that part of the code? Thanks! –  user71346 Jun 5 '13 at 2:54
1  
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]. –  J. M. Jun 5 '13 at 2:56
    
@0x4A4D. Thanks so much. I am not really good at shortcut. But is there any way to check whether our y[x] when plugged into the RHS will result to a? I think theoretically that's how we check whether our solution satisfies the DE. But when I tried y'[x] + x (y[x])^2 /.sol[[1]], it does not give the result a? Thanks. –  user71346 Jun 5 '13 at 3:08
1  
You might be interested in FullSimplify[]; see if it helps you answer your last question. –  J. M. Jun 5 '13 at 3:10
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.