Implement a restricted form of classic problem of arithmetic

Assignment Help Programming Languages
Reference no: EM132241777

Assignment -

Overview - In this assignment, you implement a restricted form of the classic problem of simplifying arithmetic expressions. You first implement two simplification operations, then a general algorithm to transform such expressions into a normal form.

The main restriction is that we only deal with the operations +, -, and *, and that the arguments are only integers and a single variable symbol x. Therefore, all expressions eventually simplify to apolynomial in x, with integer coefficients.

TYPES OF EXPRESSIONS IN THIS ASSIGNMENT

We have two main types of expressions in this assignment: Assignment 2 expressions or A2Expr are built as explained above, and polynomials in x or PExpr are represented in a specific short form.

1. Write a Lisp function: (remove-identities E)

2. Write a Lisp function: (simplify-zeroes E)

3.1 - Write a Lisp function: (simplify E)

BONUS QUESTION - Does the order of calls to remove-identities and simplify-zeroes in simplify matter? Could we get a different final result in simplify if we called these two functions in a different order?

  • If your answer is yes, give an example with two different call sequences with different results.
  • If your answer is no, give a good logical argument for why.

4. Write a Lisp function: (normalize P)

5. Write a Lisp function: (polynomial E)

5.1 Write two Lisp functions: (poly-add P1 P2) (poly-subtract P1 P2)

For these two functions, the inputs P1 and P2 are PExpr in normal form. The output should be the sum (for poly-add) or difference (for poly-subtract) of the two PExpr, also in normal form. See poly-add, poly-subtract examples in public tests.

5.2 Write a Lisp function: (poly-multiply P1 P2)

Again, the inputs P1 and P2 as well as the output are PExpr in normal form. See poly-multiply examples in public tests.

5.3 Implement polynomial, using the three helper functions.

Hint: use recursion, with the base cases:

1. integer n - represent by (n . 0)

2. atom x - represent by (1 . 1)

See polynomial examples in public tests.

6. Printing a PExpr in normal form.

Write a Lisp function: (print-pexpr P)

Instructions - Need to be done with LISP languages.

Attachment:- Assignment File.rar

Reference no: EM132241777

Questions Cloud

Propose your strategy for advertising the new product : Explore the Internet to find a multinational company for which you would enjoy building new consumer products.
Compute the total cost of ordering and carrying flour : Determine the economic order quantity. What is the average number of bags on hand? Compute the total cost of ordering and carrying flour.
State two smart goals for ge based on the case : Describe what GE could have done to improve the process of transporting the evaporator. Provide specific recommendations.
What the particular theorist was known for : Complete the following table by reordering the theorists according to the relevant date (and providing these dates), writing at least 90 words.
Implement a restricted form of classic problem of arithmetic : You implement a restricted form of the classic problem of simplifying arithmetic expressions. You first implement two simplification operations
Provide a brief summary about the challenges you faced : Provide a brief summary about the challenges you faced while completing this proposal. Select one of the five functions of management that appealed.
Evaluate the effectiveness of a planned change : Organizational development (OD) is a set of techniques for implementing a planned change to make people and organizations more effective.
Managing performance of employees is vital-yet delicate : Managing performance of employees is vital-yet delicate-responsibility. Describe potential causes of this scenario. What could manager have done differently?
What proportion of children ate the marshmallow : What proportion of children ate the marshmallow before the researcher returned to the room, and what proportion waited? What does Dr. de Posada say is the most.

Reviews

len2241777

2/24/2019 9:50:28 PM

Instructions - This is my assignment's requirements, it need to be done with LISP languages. Could you please have a look it, and I just wondering how much is it. Update 2: fixed typo in Question 2, (0 * Exp) changed to (* Exp 0). Added test cases 2.8, 3.9. 3.10 in a2-public-tests.lisp to cover more variations of multiply by zero. Update 20: added missing case (- Exp 0) in Question 1. I regret this omission, but at this point it seems easier to change the specification rather than rework all test cases to follow the old spec. Hints: To compute the product of two PExpr, "multiply them out" and normalize the result.

Write a Review

Programming Languages Questions & Answers

  Prepare a flowchart that is also a fully functional program

Using Visual Logic, design a flowchart that is also a fully functional program to add functionality to the online shopping cart. According to your design, the program must.

  Program to calculate and displays number of miles per hour

Design a program to calculate and displays the number of miles per hour over the speed limit that a speeding driver was doing

  Which quality control method should the manager adopt. why

Type I error probability is defined as the conditional probability of rejecting a good lot. Type II error probability is defined as the conditional probability of accepting a poor quality lot.

  Design-write program to enter score repetition structure

Design and write a program that asks the user to enter five test scores using a repetition structure. The program should display the letter grade for each score and the average test score at the end of the program.

  Prompt user to enter two numbers on a single line separated

Then your program will prompt the user to enter two numbers on a single line separated by a space. Your program will then validate that the two numbers input .

  Example on message-passing style

Write a procedure that produces independent first-in-first-out queue objects, using a message-passing style.

  Design and implement set of classes to model employees

Design and implement a set of classes to model the employees of a hospital: doctor, nurse, administrator, etc. Include methods in each class.

  Create while-end repetition structure includes a nested if

Create your own While-End (or For-End) repetition structure that includes a nested if-then selection structure. You decide the theme. You should provide both the pseudocode and the flowchart of your example.

  Write program for real estate agent

Write a program for a real estate agent. The program should perform the following tasks: ask users for the average house price for the each of past 5 years for a single family residence of 1500 square feet.

  What is the difference between an interpreter and a compiler

What are the general stages in the development of an expert system? What occurs in each stage?

  Writing application to accept loan amount-interest rate

Write down the application to accept a loan amount, annual interest rate, and loan period (in number of years) and displays a table with five columns.

  Develop an external css to provide style to an html document

Cascading Style Sheets are used to provide style, presentation, and layout for the HTML content of a Web page. You will develop an external CSS to provide.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd