
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
Symbolic math for ruby.
== Installation
Symbolic needs Ruby 1.9.
gem install symbolic
== Introduction
This gem can help you
Symbolic doesn't have any external dependencies.
== Tutorial
First, you need to create a symbolic variable.
x = var
angle = var :name => 'θ'
pi = var :value => 3.14
y = var { x ** 2 }
x.value = 3
Now, you can do any math operations with it.
f = 2x + 1 puts f # => 2x+1
To get value of symbolic expression you just call value:
f.value # => 7
You can accomplish the same thing with subs:
f.subs(x,3) # => 7
Or make a more complicated substitution:
f.subs(x,x2) # => 2*x2+1
If symbolic expression contains variables without value then it returns nil.
z = var (z+1).value # => nil
All symbolic expression are automatically simplified when created:
0 * x # => 0 2 + x + 1 # => x + 3 -(x-y) + 2*x # => x + y (x**2)3 / x # => x5
If you need to use a function from Math module with symbolic variable, use Symbolic::Math module.
cos = Symbolic::Math.cos(x) x.value = 0 cos.value # => 1.0
You can get a list of variables from symbolic expression:
(x+y+1).variables # => [x, y]
So you can get a list of variables without value:
(x+y+1).variables.select {|var| var.value.nil? }
You can get information about the number of different operations used in a symbolic expression:
f = (2x-y+2)x-2(xy) f.operations # => {"+"=>1, "-"=>2, ""=>3, "/"=>0, "**"=>1, "-@"=>0}
You can also take derivitives and do taylor expansions:
Symbolic::Math.cos(x**2).diff(x)
Symbolic::Math.cos(x).taylor(x,0,3)
== TODO
== Author
brainopia (ravwar at gmail.com).
I am ready to help with any questions related to Symbolic. I welcome any contribution.
FAQs
Unknown package
We found that symbolic demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.