Project

symcalc

0.0
The project is in a healthy, maintained state
SymCalc adds symbolic mathematics and calculus to your code. Create, evaluate and differentiate mathematical functions with a single method call.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

SymCalc Ruby

SymCalc Logo

Website / License: Apache-2.0 / Changelog / Ruby , C++

SymCalc (which stands for Symbolic Calculus) is a library that introduces mathematics to code, where you can declare, evaluate, and differentiate any possible maths function with a single call.

SymCalc allows to write readable and flexible code, adding a lot of functionality along the way, like this:

fx = 5 * x ** 2 + sin(x)

Instead of hard-coded functions like this:

def fx(x)
    5 * x ** 2 + Math.sin(x)
end

Contents

  • Example
  • Basic usage
  • Install
  • Learning SymCalc
  • Authors

Example

require 'symcalc'
include SymCalc

# SymCalc variable
x = var("x")

# SymCalc function
fx = x ** 2 * 5 - 4 * sin(exp(x))

# SymCalc derivative
dfdx = fx.derivative()

# SymCalc evaluate
value = dfdx.eval x: 5

puts value

Basic usage

  1. Require SymCalc:
require 'symcalc'
include SymCalc
  1. Define a variable:
x = var("x")
  1. Define a function:
fx = x ** 2
  1. Evaluate:
value = fx.eval(x: 4)
# or
value = fx(x: 4)
  1. Differentiate:
dfdx = fx.derivative
  1. Multi-variable!:
x = var("x")
y = var("y")

fxy = x ** 2 - 4 * abs(y)

dfdx = fxy.derivative(variable: x)
dfdy = fxy.derivative(variable: y)
  1. Display:
puts fx # Prints the function
  1. Run:
ruby main.rb
  1. See more on the website!

Install

Run:

gem install symcalc

Learning SymCalc

You can learn more about SymCalc on these resources:

Authors

SymCalc is currently developed and maintaned by Kyryl Shyshko (@kyryloshy)