SlideShare ist ein Scribd-Unternehmen logo
1 von 77
Downloaden Sie, um offline zu lesen
Symbolic Computation
in Perl
Mike Friedman
(friedo)
YAPC::NA 2015
Salt Lake City, UT
@friedo
Me:
Mike Friedman
(friedo)
@friedo
http://quire.com/
@quire
The Problem:
The Problem:
We have computers.
The Problem:
We have computers.
But they don't really compute.
The Problem:
We have computers.
But they don't really compute.
The Problem:
We have computers.
But they don't really compute.
==
The Problem:
Native number types in most programming languages
(including Perl)
are ints and floats.
The Problem:
Native number types in most programming languages
(including Perl)
are ints and floats.
Because that's what the microprocessor can do.
The Problem:
What about rational numbers?
The Problem:
What about rational numbers?
The Problem:
What about rational numbers?
These can only be approximated
by floating point.
The Problem:
What about irrational numbers?
The Problem:
What about irrational numbers?
Same problem.
The Problem:
What about imaginary and complex numbers?
The Problem:
What about imaginary and complex numbers?
Floats can't even approximate these.
The Solution:
We do not want to calculate with numbers.
The Solution:
We do not want to calculate with numbers.
We want to compute with symbols.
The Solution:
We do not want to calculate with numbers.
We want to compute with symbols.
We do that in software.
The Solution:
>
Example 1
Rational numbers
Example 1
Rational numbers
We start with integers.
Example 1
Rational numbers
We start with integers.
Example 1
For division, we must extend the integers.
Example 1
For division, we must extend the integers.
Example 1
We can think of them as ordered pairs.
Example 1
Rational object as an ordered pair:
Divide by greatest common factor $f to put
in lowest terms.
Example 1
Convenience subs for a, b, c, d terms:
Example 1
Arithmetic operators
Example 1
Stringification operator
Example 1
Let's try it!
Example 2
Complex numbers
Example 2
Rational numbers
We start with the real numbers.
Example 2
Rational numbers
We start with the real numbers.
Example 2
Rational numbers
We start with the real numbers.
Example 2
To solve, we must extend the real numbers.
Example 2
We can think of them as ordered pairs.
Example 2
Complex object as an ordered pair:
Example 2
Convenience subs for a, b, c, d terms:
Remember these?
Example 2
Arithmetic operators
Example 2
Stringification operator
Example 2
Let's try it!
Example 3
Linear equations
Example 3
Linear equations
standard form:
Example 3
Linear equations
standard form:
solution:
Example 3
We can think of them as ordered pairs.
Example 3
Linear object as an ordered pair:
Example 3
Solving algorithm
That's it!
Example 3
Let's try it!
Example 3
What about Rationals?
Changed integer 0 to Rational 0/1.
Overloading handles the rest.
Example 3
Let's try it!
Example 4
Quadratic equations
Example 4
Quadratic equations
standard form:
Example 4
Quadratic equations
standard form:
solution:
Example 4
We can think of them as ordered triplets.
Example 4
Quadratic object as an ordered triplet:
Example 4
Solving algorithm
Example 4
Let's try it!
Now make it work with Complex objects!
Example 4
Let's try it!
Now make it work with Complex objects!
(I'm too lazy.)
Example 5
Polynomials
Example 5
Polynomials
standard form:
Example 5
Polynomials
Example 5
We can think of them as ordered tuples
of size n+1, where n is the degree of the
polynomial.
Example 5
Polynomial object as an ordered tuple:
Example 5
Addition operator:
Example 5
Let's try it!
Example 5
How about derivatives?
Example 5
Derivative operator:
Example 5
Let's try it!
Conclusions
1. Figure out the rules for your thing.
Conclusions
Complex numbers extend the reals.
They have self-consistent rules for
arithmetic.
Conclusions
2. Eliminate extraneous information.
Conclusions
Rationals are just pairs of integers.
Complex are just pairs of reals.
Fraction bars and i are just notation.
Conclusions
3. Find a representation for your thing.
Conclusions
Ordered pairs, triplets, and tuples.
For more interesting things, you'll use
trees.
Thanks!
Symbolic Computation
in Perl
Mike Friedman
(@friedo)
github.com/friedo/perl-symbolic

Weitere ähnliche Inhalte

Ähnlich wie Basic Symbolic Computation in Perl

Basics of Programming - A Review Guide
Basics of Programming - A Review GuideBasics of Programming - A Review Guide
Basics of Programming - A Review Guide
Benjamin Kissinger
 
Logarithms and logarithmic functions
Logarithms and logarithmic functionsLogarithms and logarithmic functions
Logarithms and logarithmic functions
Jessica Garcia
 
Logarithms and logarithmic functions
Logarithms and logarithmic functionsLogarithms and logarithmic functions
Logarithms and logarithmic functions
Jessica Garcia
 
Math In Business boa
Math In Business boaMath In Business boa
Math In Business boa
raileeanne
 
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
johnnygoodman
 
Foundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematicsFoundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematics
SherwinSangalang3
 

Ähnlich wie Basic Symbolic Computation in Perl (20)

Basics of Programming - A Review Guide
Basics of Programming - A Review GuideBasics of Programming - A Review Guide
Basics of Programming - A Review Guide
 
Logarithms and logarithmic functions
Logarithms and logarithmic functionsLogarithms and logarithmic functions
Logarithms and logarithmic functions
 
Logarithms and logarithmic functions
Logarithms and logarithmic functionsLogarithms and logarithmic functions
Logarithms and logarithmic functions
 
Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2
 
Complex variable transformation presentation.pptx
Complex variable transformation presentation.pptxComplex variable transformation presentation.pptx
Complex variable transformation presentation.pptx
 
Module 1 solving inequalities notes
Module 1 solving inequalities notesModule 1 solving inequalities notes
Module 1 solving inequalities notes
 
Math Number Quantity
Math Number QuantityMath Number Quantity
Math Number Quantity
 
Rubykin
Rubykin Rubykin
Rubykin
 
Analysis of Algorithms Syllabus
Analysis of Algorithms  SyllabusAnalysis of Algorithms  Syllabus
Analysis of Algorithms Syllabus
 
Math In Business boa
Math In Business boaMath In Business boa
Math In Business boa
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and review
 
Algorithms 1
Algorithms 1Algorithms 1
Algorithms 1
 
L01 intro-daa - ppt1
L01 intro-daa - ppt1L01 intro-daa - ppt1
L01 intro-daa - ppt1
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
Tenth class state syllabus-text book-em-ap-ts-mathematics
Tenth class state syllabus-text book-em-ap-ts-mathematicsTenth class state syllabus-text book-em-ap-ts-mathematics
Tenth class state syllabus-text book-em-ap-ts-mathematics
 
Javascript breakdown-workbook
Javascript breakdown-workbookJavascript breakdown-workbook
Javascript breakdown-workbook
 
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
 
Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower bounds
 
Foundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematicsFoundation_Logic_1.pptx discrete mathematics
Foundation_Logic_1.pptx discrete mathematics
 
Machine learning by using python lesson 3 Confusion Matrix By : Professor Lil...
Machine learning by using python lesson 3 Confusion Matrix By : Professor Lil...Machine learning by using python lesson 3 Confusion Matrix By : Professor Lil...
Machine learning by using python lesson 3 Confusion Matrix By : Professor Lil...
 

Mehr von Mike Friedman

Mehr von Mike Friedman (8)

Make Your Own Perl with Moops
Make Your Own Perl with MoopsMake Your Own Perl with Moops
Make Your Own Perl with Moops
 
The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)The Perl API for the Mortally Terrified (beta)
The Perl API for the Mortally Terrified (beta)
 
21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci
 
Data Modeling for the Real World
Data Modeling for the Real WorldData Modeling for the Real World
Data Modeling for the Real World
 
CPANci: Continuous Integration for CPAN
CPANci: Continuous Integration for CPANCPANci: Continuous Integration for CPAN
CPANci: Continuous Integration for CPAN
 
Building a MongoDB App with Perl
Building a MongoDB App with PerlBuilding a MongoDB App with Perl
Building a MongoDB App with Perl
 
Building Your First App with MongoDB
Building Your First App with MongoDBBuilding Your First App with MongoDB
Building Your First App with MongoDB
 
Building Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::ClientBuilding Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::Client
 

Kürzlich hochgeladen

Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Kürzlich hochgeladen (20)

S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 

Basic Symbolic Computation in Perl