So here is what I have done. Homogeneous has several meanings, but when I use it in this post, I will mean homogeneous functions. We only care about functions of two variables, so I will also only talk about them. A function is called homogeneous of order if for some . Also, if we “pull” an out, we get , which is why the definition is often stated that the function can be written as a function of . Of course, we could do the same with and get a function of . Here is an example of a homogeneous function: . You can see that .

Now, if the coefficients and in the first order differential equation are both homogeneous functions of the same order, then the substitution or will make the equation separable. I will show how to do it for . We have by the product rule. We also have and . Because these functions are homogeneous, we can “pull out” an from each, giving us . Because we made the substitution , we already have had to assume . Thus, we can divide the whole thing by . Doing this, and expanding the remaining terms, we get . Refactoring the and terms, we get . The equation is separable! Separating variables and integrating, we get . If we had used instead, we would have gotten . This is exactly how I was able to solve these equations in SymPy. Each homogeneous equation has two possible integrals, and often the right hand side of one equation is a much harder integral than the right hand side of the other. Therefore, I did them both, and applied a little heuristic on which one to return. It prefers expressions that can be solved for y (f(x) in the case of SymPy), expressions that have evaluated integrals, and if neither of them are solvable, the shortest one, which tends to be the simplest.

Here is an example from my text book. . Astute readers of this blog may have noticed that this equation is exact. It is easier to solve that way, but we will try using the methods outlined above. First, we notice that the coeficients of and are both homogeneous of order 2, so we can make the substitution or and the equation would become seperable. If I were doing this by hand or for a homework assignment, I would make one of those substitutions and work it through, but we have the exact form above, so let’s use it just like SymPy would. and . So we get with and with (here and for the remainder of this derivation, the arbitrary constants in the two equations do not necessarily equal each other until the last step). Both integrals can be solved with a substitution of the denominator, giving, with back substituted, and . If we make , and pull the constants in front of the logs on the right hand sides in as powers, we can combine everything into logarithms. After doing that, we then take the antilog of both sides and get and . We then raise the whole equation to the power and make . We get

and

,

where

Verify as an exercise that you get the same solution by the exact differential equation methods (or don’t… you know, depending on which you’d rather do).

Of course, if that was all there was to it, I would have finished in a day. There was more. First, I had to write a function that determines if an expression is homogeneous and what order if it is. That was about 150 lines of code right there plus tests (150 lines is a lot in Python).

I also wanted it to recognize that is homogeneous because . SymPy was incapable of combining logarithms like this, so I had to write a logcombine function, which was another 100 lines of code plus tests. This came in handy, because I was also able to use it in the part above where I combined the logarithms of my answer to eliminate all of them.

Lastly, you may have noticed that my math looks much nicer in this post. It turns out that WordPress supports math using $latex <math>$. Unfortunately, I did not discover this until I had already uploaded images of almost all the math expressions in the post, so I had to go back and fix them.

Also, I was having a problem where the math wouldn’t render, but it turns out that this was an issue with me copying and pasting “$latex” and the expressions into the WordPress rich text editor. I changed my editor settings to plain text. I’m sorry, but web rich text editors do not work. And I’ve grown accustomed to seeing the source of stuff that I write having done everything in for a year and having edited Wikipedia for a while.

I wish there were a free blogging site like WordPress or Blogger that used MediaWiki or as its rendering engine. It would look nice, the formatting would be a standard thing that isn’t confusing html, and math would come out much nicer.

[...] a working Constant class, I can solve homogeneous differential equations (not to be confused with first order differential equations with homogeneous coefficients) with one case (there are several cases depending on whether the roots of the so called [...]

[...] really simple ones. I ended up XFAILing most of my implicit checksol tests. I think every single homogeneous coefficients had an implicit solution, and none of them were working with [...]

[...] First Order Differential Equations with Homogeneous Coefficients May 20092 comments [...]

Wow that was odd. I just wrote an extremely long comment

but after I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that

over again. Anyway, just wanted to say excellent blog!

Hi there, of course this article is really fastidious and I have learned lot of things from

it regarding blogging. thanks.