• Support PF! Buy your school textbooks, materials and every day products Here!

Nonlinear First order ODE: dy/dx = x + y^2

  • Thread starter toneboy1
  • Start date
  • #1
174
0

Homework Statement


I want to find the general solution for y(x) if dy/dx = x + y^2 with initial cond't y(1) = 2


Homework Equations





The Attempt at a Solution


I can't figure out how to make it linear. (Obviously I don't think it's seperable)

Any suggestions/solutions?
Thanks very much!
 

Answers and Replies

  • #3
174
0
Thanks for the repsonse. I've been looking into this all day but still not understanding it.
Specifically I don't see how in your link they got from (4) to (6).

But more puzzlingly I looked here: (you probably dont need to check)
http://www.sosmath.com/diffeq/first/riccati/riccati.html


*Please see attachment, .Gif link didn't show up properly*

Please humour me if it's like the chain rule or something, but I don't see it.

I couldn't find one single youtube video to explain any of this!

Thanks,
 

Attachments

Last edited:
  • #4
Simon Bridge
Science Advisor
Homework Helper
17,848
1,645
Yours is of form: y'=axn+by2 where a=b=n=1.

If we use form (4) then:

y' = P(x)+Q(x)y+R(x)y2 where P=x, Q=0, and R=1.

we'd substitute: y=-z'/z ans y'=(z'/z)'

hint: quotient rule - careful to keep track of that minus sign ;)

according to (6) that gives z''+xz=0
 
  • #5
174
0
Sorry, I still don't understand where y = -z'/z came from. (?) But differentiating it I got y' = -2z''/z ...? If that's right what was it equated to, to yeald z'' +xz = 0?

So I (4) (5) and (6) are still yet to make sense to me.

If you looked at that picture I attached, could you tell me, was y = 2 + 1/z ; y' = z'/z^2 some chain rule?


Thanks!!
 
  • #6
Simon Bridge
Science Advisor
Homework Helper
17,848
1,645
Sorry, I still don't understand where y = -z'/z came from.
The point of making a substitution is to turn a difficult DE into one we stand a chance to solve. It doesn't always work - there is a lot of trial and error in figuring out what kinds of substitutions to use for which kinds of equations.
what was it equated to, to yeald z'' +xz = 0
you don't equate it to anything, you substitute it into: y'=x+y2
differentiating it I got y' = -2z''/z
How?
The quotient rule is:
(f/g)'=(gf'-fg')/g2 put f=z' and g=z.

If you looked at that picture I attached, could you tell me, was y = 2 + 1/z ; y' = z'/z^2 some chain rule?
Yes. apply the sum rule, then the power rule. With the chain rule, the power rule looks like this:

(gn)' = ngn-1g' ... where g=z(x) and n=-1.

It can also be done via the quotient rule or, for that matter, the product rule.
It's called "implicit differentiation".
What level are you doing this at?
 
  • Like
Likes ebdaaa55
  • #7
174
0
Ah, that is an interesting premice.

I see. So why is f = z' and not f = -z' ?



Anyway, so solving for z = Ce^-x^2/2

Therefore y = (Ce^-x^2/2)' / Ce^-x^2/2 is that right?


Embarrassingly undergraduate level, but I haven't done anything like this for years.

I have a hard time seeing how y = 1/z could be done with the Quotent rule? (or product)

Thanks (very much) again!
 
  • #8
Simon Bridge
Science Advisor
Homework Helper
17,848
1,645
I see. So why is f = z' and not f = -z'
... same reason I don't do g=-z: avoids misplacing the "-" sign later.
I have a hard time seeing how y = 1/z could be done with the Quotent rule? (or product)
The quotient rule is a special case of the product rule with the power rule.

f/g = f.g-1 - now use product rule on RHS.

if y=1/z =f/g then f=1, f'=0, g=z, g'=z' ... now apply the quotient rule.

All this is usually covered in 1st year college pure math papers... but we all get rusty.
You should review basic differentiation to get back up to speed.

If we keep this up I'm going to have to teach you some LaTeX (which you will need if you do anything math-related next year anyway.)

Anyway, so solving for z = Ce^-x^2/2

Therefore y = (Ce^-x^2/2)' / Ce^-x^2/2 is that right?
... well, if the first line then the second ... however, what makes you think that [itex]Ce^{-x^2/2}[/itex] is a solution to [itex]z^\prime +xz = 0[/itex].

Since this is coursework - I'd be asking myself if my course has included this sort of thing: has it mentioned Riccati equations? Airy functions? Bessel equations?
 
Last edited:
  • #9
174
0
Actually I'm not sure if this question was came up in the course or if I just wonedered it myself. I'm inclined to think the latter because I don't recall Airy functions, bessel equations or Riccati being said at anypoint. It was late and I was learning vector fields or 4th order Runge Kutta and I had it scribbled down the next day.

Sorry for the lack of clarity, I should have put brackets around the exponent.

Ah! LaTeX. I've seen that sort of code on the internet before, and I was like 'h'mm that doesn't look like matlab, I wonder what it is'. Thanks for giving me that lead to investigate.

Wow, I made a terrible algebraic mistake when I tried it, I have to do my working out neater. Thanks I'll remember I can cross-check my derivative answers with a different method next time I'm unsure.


I'll give more working out next time, so you can tell me where I'm wrong quicker and I dont waste as much of your time:
for z'' + xz = 0 μ = e^(Int[x]dx) = e^(x^2/2)

z.e^(x^2/2) = Int [0.e^(x^2/2)]

z.e^(x^2/2) = C

z = Ce^(-x^2/2)

That's how I got z (I'm assuming it's wrong). Finally, I phrased most of this terribly, I should have said how exactly is: y=-z'/z ans y'=(z'/z)' ?

Thank you * 10
 
  • #10
uart
Science Advisor
2,776
9
however, what makes you think that [itex]Ce^{-x^2/2}[/itex] is a solution to [itex]z^\prime +xz = 0[/itex].
I know that was just a typo Simon as you previously had it correct :smile:, but that actually is a correct solution to that equation. The equation however was [itex]z^{\prime \prime} +xz = 0[/itex].

I'll give more working out next time, so you can tell me where I'm wrong quicker and I dont waste as much of your time:
for z'' + xz = 0

μ = e^(Int[x]dx) = e^(x^2/2)

z.e^(x^2/2) = Int [0.e^(x^2/2)]

z.e^(x^2/2) = C

z = Ce^(-x^2/2)
No, that's an "integrating factor" solution for the first order DE: [itex]z^{\prime} +xz = 0[/itex], not the 2nd order DE we're considering here.
 
  • #11
Simon Bridge
Science Advisor
Homework Helper
17,848
1,645
LaTeX is a typsetting script - defacto standard for academic papers.

Lets me write y=-z'/z => y'=-(z'/z)'=-z''/z + (z'/z)2 as
[tex]y=-\frac{z^\prime}{z} \Rightarrow y^\prime = -\left ( \frac{z^\prime}{z} \right )^\prime = -\frac{z^{\prime\prime}}{z}+\left ( \frac{z^\prime}{z}\right )^2[/tex]... or, in Liebnitz notation:[tex]y=-\frac{1}{z}\frac{dz}{dx} \Rightarrow \frac{dy}{dx} = -\frac{d}{xd}\left ( \frac{1}{z}\frac{dz}{dx} \right ) = -\frac{1}{z}\frac{d^2z}{dx^2} + \left ( \frac{1}{z}\frac{dz}{dx} \right )^2[/tex]


[itex]z=Ce^{-x^2/2}[/itex] cannot be the general solution to [itex]\frac{d^2z}{dx^2}+xz=0[/itex] because it only has one arbitrary constant - and the DE is second order.

It is, however, as you have calculated, the solution to [itex]\frac{dz}{dx}+xz=0[/itex] :)

The actual solution is [itex]z(x)=c_1\text{Ai}(kx)+c_2\text{Bi}(kx): k^3=-1[/itex] where the Ai and Bi are the Airy functions.

The solution to the 1st equation is a big mess of Bessel functions.

Considering your recent subject matter - perhaps you should try working out the specific solution you are after, with the given boundary conditions, numerically?
 
  • #12
174
0
Thank you both for pointing that out, quite an over-sight on my part. I need a lot more practice. I'm assuming Power Series wouldn't work on
z'' + xz = 0 ?

I'm now not sure I could find a specific solution given the boundary conditions. It'd be something along the lines of:

y(x) = - (c1Ai(kx)+c2Bi(kx))' / c1Ai(kx)+c2Bi(kx) (which I don't understand)
with k^3 = -1 , y = 2 and x = 1 would it not?

(You must be so sick of me by now, don't worry, I've all but conceeded to let it go now)

Thanks.
 
  • #13
Simon Bridge
Science Advisor
Homework Helper
17,848
1,645
That wolfram link I gave you tells you what circumstances will give you a solution in terms of exponentials and powers and stuff like that - this is not one of them.

One of the things about 1st order non-linear is that it is easy to make them very nasty.
This is pretty scary and it is one of a class of DEs with known solutions. Lots have no analytic solutions at all.

Just y'=f(x,y) does not look all that tough until you realize that f(x,y) can be anything.
It's basically what computers are for.

You pretty much have to go look up these special functions.
They show up in models of nature quite a lot... so you do need to know about them.
Just not yet :D
 
  • #14
174
0
I appreciate your guidance.
Had I this new found understanding of how nasty this actually is it would have saved us both a lot of time. Nevertheless I won't soon forget any of this.

Thanks again!
 
  • #15
uart
Science Advisor
2,776
9
Since the analytical solution was so horrible, here is a numerical solution to the problem. I used the following code in Matlab (or gnu Octave).

Code:
f = @(x,y) x+y.*y
opt = odeset("RelTol",1e-8,"AbsTol",1e-8,"MaxStep",4e-4,"InitialStep",4e-4)
[x,y] = ode45(f,[0,1.45],0.4805,opt);
plot(x,y)
- The value of y(0)=0.4805 was found by a "shooting" method to give y(1)=2
- The solution "blows up" at about x = 1.47, so I ended the simulation at x = 1.45


To help get some insight into the solution, and why it blows up like it does, consider the simplified separable equation [itex]y' = y^2[/itex], with y(1)=2. It is trivial to solve (by separation) and obtain:
[tex]y = \frac{1}{1.5-x}[/tex]

It's interesting that although we changed the equation to completely omit the "[itex]+x[/itex]" that the behavior near where it "blows up" is very similar, as the y^2 term completely dominates "x" here anyway. Obviously the simplified equation "blows up" at x = 1.5.

The attachments show the numerical solution of your equation and the solution of the simplified equation. (The first one is your equation and the second one the simplified separable one).
 

Attachments

Last edited:
  • #16
174
0
Forgive my ignorance, I have a lot of it, but what is the difference between 'analytical' and 'numerical'? I was using them interchaingably.

I'm new to matlab but what does the '@(x,y)' i.e the '@' symbol in that context and 'odeset' command do? Or for that matter 'ode45'? (I still do understand the result of the code)

I did a 4th order Runge-Kutta and got a similar result.

when you solved y'' = y^2 ...well I am going wrong somewhere because I got:

∫∫1/y^2 dy = ∫∫dx

(ln y)/2 = x^2 / 2


I see your matlab code but no other attachments.

EDIT:

THey just came through
 
  • #17
uart
Science Advisor
2,776
9
Forgive my ignorance, I have a lot of it, but what is the difference between 'analytical' and 'numerical'? I was using them interchaingably.
Analytically in this context literally mean "by analysis", rather than just plain dumb number crunching.

I'm new to matlab but what does the '@(x,y)' i.e the '@' symbol in that context and 'odeset' command do? Or for that matter 'ode45'? (I still do understand the result of the code)
@x() is called an "anonymous" function, it's kind of like an inline definition for simple functions. You can also define functions by writing them as ".m" files, which is the more regular way to do it.

ode45 is a 4th order runge kutta ode solver. odeset is a companion function to create a vector of options that ode45 needs (to set things like stepsize and tolerances). It will take default values if you don't use odeset, but for tricky equations like this it's best to manually set a small stepsize.

I did a 4th order Runge-Kutta and got a similar result.
Not surprising, as this was also a 4th order runge kutta. :smile:

when you solved y'' = y^2 ...well I am going wrong somewhere because I got:

∫∫1/y^2 dy = ∫∫dx

(ln y)/2 = x^2 / 2...
No, [itex] \int (1/y^2) dy [/itex] is just [itex](-y^{-1} + C)[/itex], it's not log().
 
Last edited:
  • #18
Simon Bridge
Science Advisor
Homework Helper
17,848
1,645
Putting it simply...
Analytic(al) solutions will give you the actual equation in a form where you can plug numbers in and get answers out the usual way - numerical solutions just give you a bunch of numbers.

The term "analytic" is also a technical term in philosophy - closely related.
 
  • #19
174
0
Fancy that. That matlab info will be sure to come in useful.

No, [itex] \int (1/y^2) dy [/itex] is just [itex](-y^{-1} + C)[/itex], it's not log().
Ah, yes.
But then don't you need to integrate it again, so it would become something like

∫∫(1/y^2) dy = - ln |y| + Cy + C1 (Those constants don't look right) ?



Ah, so the numerical solution is the answer you get from puting numbers in the analytical solution? :P
 
  • #20
uart
Science Advisor
2,776
9
Ah, yes.
But then don't you need to integrate it again, so it would become something like

∫∫(1/y^2) dy = - ln |y| + Cy + C1 (Those constants don't look right) ?
No, the original DE was only first order [itex]y' = y^2 + x[/itex], so the simplified separable equation I considered was just [itex]y' = y^2[/itex] (first order). Unfortunately the second order equation [itex]y'' = y^2[/itex] wouldn't separate like that anyway.


Ah, so the numerical solution is the answer you get from puting numbers in the analytical solution? :P
Not really, that would probably just be called plotting the analytic solution. Take a look a the simplest type of DE solver like Eulers method ( http://en.wikipedia.org/wiki/Euler_method ) to get an understanding of what it really means to solve a DE numerically.
 
  • #21
174
0
You are ofcourse right, I just looked. I could swear it was y′′=y^2 before.
So why could we not separate y′′=y^2, is there an easy way of doing that? (also do the constants from integration integrate like that from the double integral?)

Ah, I understand what Simon meant now.
 

Related Threads on Nonlinear First order ODE: dy/dx = x + y^2

Replies
3
Views
5K
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
3
Views
1K
Replies
2
Views
2K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
2
Views
1K
  • Last Post
Replies
8
Views
2K
  • Last Post
Replies
4
Views
408
  • Last Post
Replies
9
Views
16K
  • Last Post
Replies
8
Views
4K
Top