1 / 4

Notations for Writing Expressions

Notations for Writing Expressions. There are multiple ways to write a mathematical expression. Each way constitutes a distinct syntax . Regardless of the syntax, the expression has a particular meaning. This is its semantics . Examples: a + b Infix notation

gzifa
Download Presentation

Notations for Writing Expressions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Notations for Writing Expressions • There are multiple ways to write a mathematical expression. • Each way constitutes a distinct syntax. • Regardless of the syntax, the expression has a particular meaning. This is its semantics. • Examples: • a + b Infix notation • sum(a, b) Prefix ("Polish") notation • (+ a b) "Cambridge Polish" notation • a b + Postfix ("Reverse Polish") notation

  2. Why "Polish", "Reverse Polish", etc? • The syntactic structure of expressions was considered by Jan Lukasiewicz, a Polish mathematician, in the early 1900s. • (So it's "Polish" as from Poland, not "polish" like shoe polish.) • Polish, or prefix, notation is commonly found in programming language functions (or methods) • The LISP language uses Cambridge Polish notation • RPN, or Reverse Polish Notation, seems to reflect how computers perform operations – get the operands first, then operate on them. • RPN, is notable for not requiring the use of parentheses to write any expression. • HP scientific calculators were based on RPN for years.

  3. What is "more natural?" • Most people are used to infix notation, but consider: • Elementary arithmetic by hand is done in postfix. 7 + 8 15

  4. A complex example: Quadratic Formula • "by hand": • Infix:X = ( -b ± sqrt( b * b – 4 * a * c ) / (2 * a) • RPN:Xbnegbb * 4 a * c * - sqrt ± 2 a * / =

More Related