digitalmars.D - SymRational, Computer Algebra
- dsimcha (31/31) Oct 11 2009 I've been thinking about where a Rational struct could lead, and realize...
- Andrei Alexandrescu (3/18) Oct 11 2009 What's CAS?
- dsimcha (3/21) Oct 11 2009 CAS = computer algebra system. Basically, it's a system capable of doin...
- Phil Deets (8/55) Oct 12 2009 I think CAS capabilities would be much better for a third-party library ...
I've been thinking about where a Rational struct could lead, and realized that the next step is to give D some capabilities for dealing with symbols. For example, it would be nice to have something like: auto foo = symRational!SomeBigInt("1 / e + pi / 2 + G"); // Do a whole bunch of manipulations on foo. writeln(foo); // Symbolic expression. writeln(toReal(foo, constVal("G", 6e-11), constVal("pi", 3.14), constVal("e", 2.718)); Of course, now we're starting to talk about building a basic computer algebra system into Phobos, or at least into some stand-alone lib. While we clearly don't have the manpower to do a "real" CAS, some basic CAS-like capabilities would be nice. Programmers in most languages tend to use floating-point arithmetic as their default way of doing math. It really only makes sense to do this when speed is more important than precision or interpretability of the answer. However, it seems to get used even when this isn't the case simply because it's what's readily available. If D/Phobos had some built-in (very basic) CAS-like capabilities that were as easy to use as floats, people might actually consider using either symbolic or numerical manipulation on the relevant tradeoffs rather than just choosing numeric because it's what's easily available. The problem with using a CAS's builtin language whenever you want basic CAS-like capabilities is that it's too domain-specific. You can't easily integrate it into a larger program that requires a full-fledged general purpose programming language. The beauty of D is that it has so many features for library designers that libraries can start to look like DSLs yet still integrate smoothly with the general-purpose subset of D. Half the reason why I wrote the dstats statistics lib was to prove this concept, since similar issues arise in performing statistical calculations. The question, then, becomes, how far do we go toward trying to put some basic CAS-like capabilities like symbolic arithmetic into Phobos? Could things like this really be D's killer application?
Oct 11 2009
dsimcha wrote:I've been thinking about where a Rational struct could lead, and realized that the next step is to give D some capabilities for dealing with symbols. For example, it would be nice to have something like: auto foo = symRational!SomeBigInt("1 / e + pi / 2 + G"); // Do a whole bunch of manipulations on foo. writeln(foo); // Symbolic expression. writeln(toReal(foo, constVal("G", 6e-11), constVal("pi", 3.14), constVal("e", 2.718)); Of course, now we're starting to talk about building a basic computer algebra system into Phobos, or at least into some stand-alone lib. While we clearly don't have the manpower to do a "real" CAS, some basic CAS-like capabilities would be nice.What's CAS? Andrei
Oct 11 2009
== Quote from Andrei Alexandrescu (SeeWebsiteForEmail erdani.org)'s articledsimcha wrote:CAS = computer algebra system. Basically, it's a system capable of doing math symbolically as opposed to just numerically.I've been thinking about where a Rational struct could lead, and realized that the next step is to give D some capabilities for dealing with symbols. For example, it would be nice to have something like: auto foo = symRational!SomeBigInt("1 / e + pi / 2 + G"); // Do a whole bunch of manipulations on foo. writeln(foo); // Symbolic expression. writeln(toReal(foo, constVal("G", 6e-11), constVal("pi", 3.14), constVal("e", 2.718)); Of course, now we're starting to talk about building a basic computer algebra system into Phobos, or at least into some stand-alone lib. While we clearly don't have the manpower to do a "real" CAS, some basic CAS-like capabilities would be nice.What's CAS? Andrei
Oct 11 2009
On Sun, 11 Oct 2009 12:24:57 -0500, dsimcha <dsimcha yahoo.com> wrote:I've been thinking about where a Rational struct could lead, and realized that the next step is to give D some capabilities for dealing with symbols. For example, it would be nice to have something like: auto foo = symRational!SomeBigInt("1 / e + pi / 2 + G"); // Do a whole bunch of manipulations on foo. writeln(foo); // Symbolic expression. writeln(toReal(foo, constVal("G", 6e-11), constVal("pi", 3.14), constVal("e", 2.718)); Of course, now we're starting to talk about building a basic computer algebra system into Phobos, or at least into some stand-alone lib. While we clearly don't have the manpower to do a "real" CAS, some basic CAS-like capabilities would be nice. Programmers in most languages tend to use floating-point arithmetic as their default way of doing math. It really only makes sense to do this when speed is more important than precision or interpretability of the answer. However, it seems to get used even when this isn't the case simply because it's what's readily available. If D/Phobos had some built-in (very basic) CAS-like capabilities that were as easy to use as floats, people might actually consider using either symbolic or numerical manipulation on the relevant tradeoffs rather than just choosing numeric because it's what's easily available. The problem with using a CAS's builtin language whenever you want basic CAS-like capabilities is that it's too domain-specific. You can't easily integrate it into a larger program that requires a full-fledged general purpose programming language. The beauty of D is that it has so many features for library designers that libraries can start to look like DSLs yet still integrate smoothly with the general-purpose subset of D. Half the reason why I wrote the dstats statistics lib was to prove this concept, since similar issues arise in performing statistical calculations. The question, then, becomes, how far do we go toward trying to put some basic CAS-like capabilities like symbolic arithmetic into Phobos? Could things like this really be D's killer application?I think CAS capabilities would be much better for a third-party library than for Phobos. The Phobos developers may not be interested in improving it like the maintainers of a third-party library would. Also, you wouldn't have to tie the releases of the CAS library to the Phobos releases if it were a third-party library. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Oct 12 2009