Archived

This topic is now archived and is closed to further replies.

Differential Equation Class

This topic is 5894 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey: I am trying to write/look for a class in C++ that solves differential equations. For example, you tell it x^13 and it spits out 13x^12, something like that, doesn''t have to be extremely complicated. Any and all help is appreciated. Thanks, -Vic Go away or I will replace you with a regular expression.

Share this post


Link to post
Share on other sites
Well it would be extremely complicated to create such a class/program/whatever. I do know of at least one program that already exists which does the job: Derive from http://www.chartwellyorke.com/ But it''s not cheap, and that is only logical because it''s a HUGE undertaking to do such a thing.

Share this post


Link to post
Share on other sites
The example you give is just to take the derivative of x13. This is NOT the solution to a differential equation. Actually, y(x) = x13 is the general solution to the differential equation:

dy/dx = 13x12

And so instead of solving the equation, you''ve taken the solution and created the differential equation.

If you are merely wanting to take derivatives, then you should be able to write a small program that differentiates simple polynomials. As in your example it is not complex. You could even expand it to differentiate things like sin and cos quite easily. Once you get into more complex things, such as products like x2sin(x), or whatever, you''d probably want to use some kind of lexical parser (lexx/yacc?) to identify patterns that could then be matched to a standard table of integrals. In general, you''d need to handle recursive patterns.

The s/w "Maple V" does symbolic calculus, but again it is not cheap. And its a software product, not source code for C++.

As for SOLVING differential equations symbolically, again you''d want to use the lexical parser to look for common patterns that have known closed form or series solutions. For arbitrary differential equations, there often is no closed form solution and it has to be done numerically using either finite difference, finite element, or finite volume methods.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
Alright, thanks for that. I figured it would be somewhat complex, but didn''t think it would be that much, seeing as my TI-83+ can create a differential equation, so to speak.

I''ll continue my search then, thanks!

-Vic

Go away or I will replace you with a regular expression.

Share this post


Link to post
Share on other sites
Some differential equations are complicated. But not all. I don''t know exactly why you want to do this, but if its just for your own experience---or to help a particular project that only requires limited functionality, why not try? Differential equations are usually solved by recognizing a pattern and matching to a standard solution (may require change of variables), or numerically. Why not try to write a program that can solve some common DiffEq''s? (I would recommend that you only start with linear DiffEq''s.)

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
Mr. Rhodes, thanks for your replies. I am trying to make a differential class for several reasons:

1. To incorporate it, somehow, into a 3D game engine I want to write for school.
2. To better my programming.
3. To understand Calculus better.

Thanks for your suggestions again.

-Vic

Share this post


Link to post
Share on other sites
Well, if you are in school then I would recommend buying MathCAD, Mathematica, Maple or a similar package. I know that MathCAD and Mathematica are both callable from applications and believe Maple is since it is the CAS engine for MathCAD. You can get acedemic versions of any of them for around $100. That isn''t necessarily instead of writing a class or set of classes to deal with symbolic equations. Rather the idea is to understand the API they provide. Particularly how they represent equations.

Representing and manipulating an equation is really the starting point. As examples the ability to expand, simpify, solve, factor and convert to partial fractions would be a significant second step. The first step would be able to take an equation entered by the user, store it and later evaluate it. So a first application might be to do a graphing calculator type of program. Once you can do that you can numerically differentiate and integrate. There are also numerical methods for solving differential equations although I think that is a bit more advanced. It most likely would take you years to build up a code base to do what you want.

That is the advantage of using a CAS package. If your main interest is games then before putting years into this it would be a good idea to figure out if it is going to be useful. Basically you need a proof of concept. Once you have that proof of concept the cost of licensing a CAS engine to distribute with your game can easily justify your efforts in developing your own. If you were an established game development company with a specific opportunity cost it might make more sense to license, but when you lack capital it is do it yourself or don''t do it at all. So all you really need to determine is whether it is worth doing.

Share this post


Link to post
Share on other sites