0.0
No commit activity in last 3 years
No release in over 3 years
This is a proof-of-concept experiment inspired by Sage
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

symbolic¶ ↑

This is a proof-of-concept experiment to handle symbolic expressions in Ruby, inspired by Sage.

Symbolic expressions can be built with Ruby syntax in a symbolic block, by declaring variables with var:

symbolic do
  var :x
  expr = 2+x                         # now expr contains a symbolic expression
  puts expr                          # -> (2 + x)
  puts eval(expr)                    # -> (2 + x)
  self.x = 1.5
  puts eval(expr)                    # -> 3.5
  puts eval(expr/7)                  # -> 0.5
  var :y
  poly = 3*x**3 - x**2 - y*x + 7
  puts eval(poly)                    # -> ((7.875 - (y * 1.5)) + 7)
  puts eval(poly, :y=>5.0)           # -> 7.375
end

Functions can be defined with fun:

symbolic do
  fun(:sqr){|x| x*x}
  var :x
  expr = sqr(sin(x))
  puts expr             # -> sqr(sin(x))
  self.x = 1.5
  puts eval(expr)       # -> 0.994996248300223
end

Similar project¶ ↑

github.com/brainopia/symbolic is a similar, more complete project. Because of this the gem released by this project has been renamed to symbolic-math. Note that this project’s pretensions are more limited than brainopia’s; I only intend to play with syntax to do symbolic Math in Ruby, not to implement any relevant symbolic math functionality.

Note on Patches/Pull Requests¶ ↑

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2009 Javier Goizueta. See LICENSE for details.