/ symcalc-ruby Public

Symbolic mathematics and calculus in Ruby

You must be signed in to change notification settings

# symcalc/symcalc-ruby

## Folders and files

NameName
Last commit message
Last commit date

# SymCalc Ruby

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```

## 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`

## Authors

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

Symbolic mathematics and calculus in Ruby

## Releases 1

SymCalc Ruby 1.0.0 Latest
Jul 29, 2024

## Packages 0

No packages published

•
•