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

In summary, the person is trying to solve a Riccati equation but still has trouble understanding it. They say that if they use form (4), then y'=(z'/z)' and y=-z'/z. They also say that if they keep solving for z=Ce^-x^2/2, y=/(Ce^-x^2/2)' / Ce^-x^2/2. They mention that if they make a mistake in their algebraic work, they should review basic differentiation.
  • #1
toneboy1
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!
 
Physics news on Phys.org
  • #3
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 don't 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

  • img4.gif
    img4.gif
    11.4 KB · Views: 839
Last edited:
  • #4
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
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
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
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
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
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 don't 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
Simon Bridge said:
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].

toneboy1 said:
I'll give more working out next time, so you can tell me where I'm wrong quicker and I don't 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
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
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
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
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
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.45To 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

  • de1.jpg
    de1.jpg
    11.9 KB · Views: 558
  • de2.jpg
    de2.jpg
    10.1 KB · Views: 518
Last edited:
  • #16
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 / 2I see your MATLAB code but no other attachments.

EDIT:

THey just came through
 
  • #17
toneboy1 said:
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
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
Fancy that. That MATLAB info will be sure to come in useful.

uart said:
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
toneboy1 said:
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
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.
 

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

What is a nonlinear first order ODE?

A nonlinear first order ODE is a type of differential equation that involves a function and its derivative, where the function and/or derivative contain terms that are not linear (i.e. do not have a constant coefficient).

How do you solve a nonlinear first order ODE?

Solving a nonlinear first order ODE involves finding a function that satisfies the equation. This can be done through various methods such as separation of variables, substitution, or integrating factors.

What is the general solution of dy/dx = x + y^2?

The general solution of dy/dx = x + y^2 is y = -1/(x + C), where C is a constant. This can be obtained by solving the differential equation using the method of separation of variables.

Can you give an example of a real-life application of a nonlinear first order ODE?

One example of a real-life application of a nonlinear first order ODE is in population growth models. The equation can represent the change in population size over time, where the population growth rate is not constant but dependent on factors such as resources and competition.

How is a nonlinear first order ODE different from a linear first order ODE?

The main difference between a nonlinear first order ODE and a linear first order ODE is that the former involves terms that are not linear, while the latter only involves terms that are linear (i.e. have a constant coefficient). This makes the solution to a nonlinear first order ODE more complex and often requires numerical methods to approximate the solution.

Back
Top