Project

rucas

0.0
No commit activity in last 3 years
No release in over 3 years
The beginnings of a computer algebra system in ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.3.3

Runtime

>= 0
 Project Readme

rucas¶ ↑

rucas.rubyforge.org

github.com/jdleesmiller/rucas

DESCRIPTION¶ ↑

The beginnings of a Computer Algebra System in ruby. Supports basic simplification of symbolic expressions over the real numbers. Expressions can be entered and manipulated using standard ruby.

This is at a very early stage; many things may change.

SYNOPSIS¶ ↑

require 'rubygems'
require 'rucas'

# basic algebraic simplification
Rucas.code {
  var :x
  var :y
  ((x + log[e] - x)**y).simplify
}.to_s                  #=> "1"

# manipulate symbols using standard ruby code
Rucas.code {
  var :x
  var :y
  var :z
  foo = [x,y,z].sum
  foo ** 2
}.to_s                  #=> "(x + y + z)**2"

# build symbolics into ruby objects
class Foo
  include Rucas::Symbolic
  def initialize
    var :p
    var :q
  end

  def bar
    (p + 1) / (q - p)
  end
end
Foo.new.bar.to_s        #=> "(p + 1) / (q - p)"

# build expression trees
Rucas.code {
  var :p
  1 + p
}                       #=> #<struct Rucas::AddExpr op=:+, lhs=#<struct
                            Rucas::LiteralExpr value=1>, rhs=#<struct
                            Rucas::VarExpr name=:p>>

NOTES¶ ↑

  • Run an interactive session with the rucas command; the interactive rucas is built on irb.

  • The implementation is based on the source code for Norvig’s Paradigms of AI Programming (PAIP), but rucas is not yet as complete as the macsyma in Norvig’s book.

PROBLEMS¶ ↑

  • Simplification is quite dumb, because it doesn’t understand much about commutativity and associativity.

  • Doesn’t do differentiation or integration (but could in the future).

  • Doesn’t support many elementary functions (just log and exp and the moment).

  • Doesn’t integrate with other CAS systems (e.g. maxima) (but could in the future).

  • Doesn’t do anything with logical conditions on variables (e.g. x > 0).

RELATED PROJECTS¶ ↑

INSTALL¶ ↑

On *nix systems,

sudo gem install rucas

should do it.

To run the interactive rucas, you should just be able to type rucas. If it doesn’t work, you may need to change your PATH settings. The procedure for this is currently to run

gem env

and look at the EXECUTABLE DIRECTORY; then run

echo $PATH

and make sure that the executable directory is on your path. If it’s not, you will have to add it (search for “add directory to path”).

LICENSE¶ ↑

Copyright © 2009, 2010 John Lees-Miller

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.