#!/usr/bin/env ruby # This code comes from http://ruby-it.org/pages/Numeri+Complessi # Check the page for copyright notice and explanations >> require 'complex' => true >> a=Complex.new 10, 20 => Complex(10, 20) >> a+ 15 => Complex(25, 20) >> 10+a => Complex(20, 20) >> Complex.polar 100, 45 #raggio, gradi => Complex(52.532198881773, 85.0903524534118) >> Math.sqrt 10 => 3.16227766016838 >> require 'complex' => true >> Math.sqrt( Complex.new(1,2)) => Complex(1.27201964951407, 0.786151377757423) >> Math.sqrt 10 => 3.16227766016838 >> require 'complex' => true >> require 'yaml' => true >> Complex(1,2).to_yaml => "--- 1+2i"