I'd like to write a program to integrate derivatives to save time on calc homework and get extra credit in the class. I'm not completely sure where to start. I'm just looking for some tips from others who understand what I'm going to do and any suggestions. Thanks, Matt

on 2006-04-27 21:30

on 2006-04-27 21:49

SleepJunkie wrote: > I'd like to write a program to integrate derivatives to save time on > calc homework and get extra credit in the class. I'm not completely sure > where to start. > > I'm just looking for some tips from others who understand what I'm going > to do and any suggestions. > > Thanks, > Matt Hm... you'll probably strengthen your derivation and integration skills more if you actually solved the problems yourself. ;) If you really need to have a computer work them out (such as to check your answers), why not just use one of Mathematica, Maple, Matlab or IDL, which your school probably has installed somewhere. Personally, it sounds to me like too much work to write something yourself whose answers you could be confident about. Pistos

on 2006-04-27 21:58

On 4/27/06, Pistos C. <removed_email_address@domain.invalid> wrote: > > Matt > Pistos > > -- > Posted via http://www.ruby-forum.com/. And just to add to that a bit - doing integration with a computer is relatively straightforward if you are talking about definate integrals and solving them using numerical methods. If you are trying solve them symbollically, even integrating something as simple as x^2 is not trivial.

on 2006-04-27 22:01

Pistos C. wrote: > > Hm... you'll probably strengthen your derivation and integration skills > more if you actually solved the problems yourself. ;) If you really I agree. Matt didn't say how he wants to solve them, but if he wants to write something to solve them symbolically, rather than numerically, he may actually learn more. But then again, that's not a task I'd want to take on. --Steve

on 2006-04-27 22:04

I can integrate and derive perfectly fine. It's more of "I just want to do this" then "Do my homework" program. If I do it, however, I'll get extra credit, which is always good. I guess this is going to be harder than I thought. I'll have to program in the chain rule, quotient rule, product rule, and others.. More suggestions are welcome :)

on 2006-04-27 22:46

On Apr 27, 2006, at 2:04 PM, SleepJunkie wrote: > > -- > Posted via http://www.ruby-forum.com/. > I think you're going to have to look at the source of some other computer algebra systems to see and how its done. This isn't a trivial problem, and it's not just a matter of knowing all the rules, especially for integrations. (Try writing a program to do integration by parts, how is it going to decide what u and v should be for instance?)

on 2006-04-27 22:56

Logan C. wrote: > I think you're going to have to look at the source of some other > computer algebra systems to see and how its done. This isn't a > trivial problem, and it's not just a matter of knowing all the rules, > especially for integrations. (Try writing a program to do integration > by parts, how is it going to decide what u and v should be for > instance?) Maxima is an open source symbolic solver/integrator, so you could start by looking how they do it.

on 2006-04-27 22:59

Just for normal college/university level calc1&2, you will need approximately 300 rules to do general integration. Derivation can be done with only about 15rules though (though in general the rules are a bit tougher)

on 2006-04-27 23:46

After hearing all of this and talking to a co-worker (programmer who has been doing it much longer than I have), I have decided to just go with making a program for differentiation. I will look at the Maxima source code, thanks. I'll see how this goes :) Also, if you're curious, I'm just doing calculus of a single-variable.

on 2006-04-28 02:49

First of all I'd like to disagree with everybody who told you you'd be better off doing your homework. I think you'll learn **more** about integrating derivatives by automating the process than you will doing it by hand a hundred million times. Second, if I recall correctly, there's example code for this in "Higher-Order Perl," although obviously the author of that particular book didn't use Ruby to do it. -- Giles B. http://www.gilesgoatboy.org

on 2006-04-28 03:01

Giles B. wrote: > First of all I'd like to disagree with everybody who told you you'd be > better off doing your homework. I think you'll learn **more** about > integrating derivatives by automating the process than you will doing > it by hand a hundred million times. > > Second, if I recall correctly, there's example code for this in > "Higher-Order Perl," although obviously the author of that particular > book didn't use Ruby to do it. > > -- > Giles B. > http://www.gilesgoatboy.org Thanks a lot for that book, I'll have to check the book store and read up on it or run to the library. And I agree too that I'd learn more that way, but I'm doing great in calc now. I could, however, distribute it to the morons in the class ;)

on 2006-04-28 03:29

So.. I have no idea where to start. I'm starting to think even this is too big for me to do. I've only made small programs before. I'd really like a place to start, or something to help get me started. I'm going to have to be able to parse so many different things. Maybe I need to learn more Ruby. I'd love to do this, though.

on 2006-04-28 03:40

On Apr 27, 2006, at 4:29 PM, SleepJunk13 wrote: > So.. I have no idea where to start. Maybe you should figure out a format for storing polynomials, make a class to deal with this, and then create some basic functions like multiply or whatever you think you'll need. or find a library to do this. -- Elliot T. http://www.curi.us/blog/

on 2006-04-29 07:08

Basic symbolic differentiation is a piece of cake. It's usually done as an exercise in Lisp programming, but there's no reason on earth you can't do it in Ruby, or for that matter, any language that supports recursion. Hell, I've seen it done in Fortran! :) Symbolic integration is quite a bit more difficult. However, there are quite a few open-source computer algebra packages you can learn the algorithms from. There is absolutely no need to spend the money on Mathematica or Maple -- both quite expensive outside of a university -- just to get some integrals done. Check out Maxima and Axiom. I think a high-school-level differentiation routine would make an excellent Ruby quiz, now that I think of it. SleepJunkie wrote: > I can integrate and derive perfectly fine. It's more of "I just want to > do this" then "Do my homework" program. If I do it, however, I'll get > extra credit, which is always good. > > I guess this is going to be harder than I thought. I'll have to program > in the chain rule, quotient rule, product rule, and others.. > > More suggestions are welcome :) > > -- M. Edward (Ed) Borasky http://linuxcapacityplanning.com

on 2006-04-29 07:11

Hmmm ... there's actually a C++ library for writing computer algebra function -- it's called "ginac". Maybe all you need to do is write Ruby bindings to ginac and call the ginac functions. I'm not sure what "high-level" classes it has, like for differentiation, integration or equation solving. Elliot T. wrote: > -- Elliot T. > http://www.curi.us/blog/ > > > > > -- M. Edward (Ed) Borasky http://linuxcapacityplanning.com

on 2006-04-29 08:27

As this is a calc student, I would assume he want to write the whole thing.

on 2006-05-03 21:08

Elliot T. <removed_email_address@domain.invalid> writes: >> So.. I have no idea where to start. > > Maybe you should figure out a format for storing polynomials, make a > class to deal with this, and then create some basic functions like > multiply or whatever you think you'll need. or find a library to do > this. http://www.math.kobe-u.ac.jp/~kodama/tips-RubyPoly.html

on 2006-05-09 06:28

I've been thinking about doing something like this myself, just for shits and giggles, and I was just wondering if it would be good to use infinite series expressions to integrate. It seems like it would be a more standardized way of integration (unless an ln shows up somewhere). Perhaps once you can write something that will integrate polynomial expressions, it would be reasonable to use infinite series like this. However, I haven't really taken the time to mess with it. I don't know how much calculus you know, either, so I don't know if you really want to teach yourself Taylor and Maclauren series just to do this. If you're really into it, though, that way seems possible.

on 2006-05-09 07:58

A look at Axiom or Maxima (open source) or Derive (closed source but very inexpensive, especially to college students) will pretty much show you what the state of the art in antidifferentiation algorithms is. The name I remember is Risch, although there may be some others. Justin Bangerter wrote: > > -- M. Edward (Ed) Borasky http://linuxcapacityplanning.com

on 2006-05-09 08:20

I know nada about calc, but for what it's worth, it's used as a teaching exercise in the Perl book I mentioned (and is probably adapted from the Lisp teaching exercises somebody else mentioned). Of course it's heavily dependent on recursion, if I recall correctly. -- Giles B. http://www.gilesgoatboy.org

on 2009-02-05 20:00

Hey, has anyone successfully created a program with Ruby that uses maxima or any other "reasonably cheap" (or free) math programs?? If so, can you point me to any resources?? http://www.ruby-forum.com/topic/177704#new

on 2009-02-05 22:06

Richard S. wrote: > Hey, has anyone successfully created a program with Ruby that uses > maxima or any other "reasonably cheap" (or free) math programs?? If so, > can you point me to any resources?? > > http://www.ruby-forum.com/topic/177704#new I'm not sure what you mean by Ruby "using" maxima. Maxima is a stand-alone program, and it has a wxWidgets GUI called "wxMaxima" and an X-Windows GUI called XMaxima. If you just want to access maxima as a "server" from Ruby, I'm sure there's a way to start it up using "system" and pass it input / capture its output via pipes. What's the application goal / use case / problem you're trying to solve? Are you trying to use symbolic mathematics as part of a Ruby application? -- M. Edward (Ed) Borasky I've never met a happy clam. In fact, most of them were pretty steamed.

on 2009-02-05 22:50

By "using" maxima, I mean accessing maxima via a pipe in Ruby. I am developing a web based mathematical application that can integrate symbolically among other things. I don't have to use maxima or even ruby for that matter but I would like to if possible. I understand the concept of "system" access but during the execution I've hit two snags First, If i run this code multiple times: max = IO.popen("maxima", "w+") max.puts "1+1;" 8.times {max.gets} #needed to rid of unneeded lines response = max.gets max.close I get a new instances (found via ps -A) of "ttys000 0:00.00 (sbcl)" every time i run the code. And i can't kill this "sbcl" via "kill pid". And after enough runs, I have to restart my computer. Second, I am unable to just get the last line from maxima without running "8.times {max.gets}." If i try to execute "max.gets" after maxima has reached the last line, I get an error (and no return to ruby). While i can get around this problem, (via 8.times ) it isn't exactly best practices. So, any suggestions??

on 2009-02-06 00:01

> Second, I am unable to just get the last line from maxima without > running "8.times {max.gets}." If i try to execute "max.gets" after > maxima has reached the last line, I get an error (and no return to > ruby). While i can get around this problem, (via 8.times ) it isn't > exactly best practices. AFAIK the maxima gui itself passes the code on to an inferior lisp process that does the actual work. I don't know how much work that would be to implement that protocol but maybe looking at the gui's source code would help to give you an idea of how to communicate with maxima reliably.

on 2009-02-06 00:18

There are a number of web apps that do this sort of thing -- live math on the web. It sounds to me like you're re-inventing a wheel here. Of course, most of said web apps are not in Ruby, because Ruby and Rails weren't popular when they were designed. On Thu, Feb 5, 2009 at 12:49 PM, Richard S. <removed_email_address@domain.invalid> wrote: > 8.times {max.gets} #needed to rid of unneeded lines > ruby). While i can get around this problem, (via 8.times ) it isn't > exactly best practices. > > So, any suggestions?? > -- > Posted via http://www.ruby-forum.com/. > > -- M. Edward (Ed) Borasky I've never met a happy clam. In fact, most of them were pretty steamed.

on 2009-02-06 18:31

For reinventing the wheel...the best candidate for copying is WMI (uses maxima) http://matek.hu/ which is kind enough to give its src code away for free, unfortunately its PHP and I haven't had anyone who knows enough about PHP & Ruby to help me figure out what i'm doing wrong: Here is the PHP: http://pastie.org/380232 Thanks Tom for the Idea, i found an article about converting ruby code to lisp here: http://onestepback.org/index.cgi/Tech/Ruby/LispInRuby.red so calling commands naively may be a good work around. I also discovered Sage an open source math program written in python http://www.sagemath.org/ I haven't done anything with python before, but I have some friends who rave django, so it may just be easier to go that route. Either way I'll let everyone know what ended up meeting my needs.

on 2009-02-06 18:56

Richard S. wrote: > I also discovered Sage an open source math program written in python > http://www.sagemath.org/ I haven't done anything with python before, but > I have some friends who rave django, so it may just be easier to go that > route. Either way I'll let everyone know what ended up meeting my needs. Sage is an outstanding project, even though it is written in Python. :) I'm on their mailing list and I've done a fair amount of testing of it. In terms of tools for day-to-day use by working mathematicians, I don't know of anything better in the open source world, and they are closing in on the expensive proprietary packages like Mathematica and Matlab. Funny you should mention Sage, since their slogan is, or used to be, "Building the car, not re-inventing the wheel." :) -- M. Edward (Ed) Borasky I've never met a happy clam. In fact, most of them were pretty steamed.

on 2009-02-07 18:07

On Fri, Apr 28, 2006 at 1:31 AM, SleepJunkie <removed_email_address@domain.invalid> wrote: > I'd like to write a program to integrate derivatives to save time on > calc homework and get extra credit in the class. I'm not completely sure > where to start. > http://en.wikipedia.org/wiki/Risch_algorithm There's apparently an algorithm out there that can do symbolic integration of any elementary function, and returns either its antiderivative, or that its antiderivative is not expressible in terms of elementary functions. The only problem that it requires at several points to determine whether two expressions are equal, and that, unfortunately, is difficult, and in some cases actually impossible (undecidable) depending on what functions you allow. See http://en.wikipedia.org/wiki/Richardson's_theorem There's also a whole theory built up from this called differential Galois theory, which extends ideas originally developed by Ã‰variste Galois for the solvability of polynomial equations into solving differential equations, which is really what antidifferentiation is all about: http://en.wikipedia.org/wiki/Differential_Galois_theory You're treading in deep water here, brother. Beware.