Socket
Book a DemoInstallSign in
Socket

symbolic-math

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

symbolic-math

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

= 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 = 3x3 - x2 - yx + 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

http://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

Copyright (c) 2009 Javier Goizueta. See LICENSE for details.

FAQs

Package last updated on 10 Dec 2009

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.