require 'symengine' x = SymEngine::Symbol.new('x') expression = x**2 + 2*x + 1 # مشتقگیری puts expression.diff(x) # حل معادله puts SymEngine.solve(expression, x)