Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Numerical Methods (a) Floating point representation: (i) If a single-precision floating point number is added to a double-precision floating point number, what can we say

Numerical Methods 

(a) Floating point representation: (i) If a single-precision floating point number is added to a double-precision floating point number, what can we say about the expected and worst-case representation errors in the result? [2 marks] (b) Floating point rounding: (i) Would a round-to-odd rule introduce a different amount of bias compared with the normally used round-to-even rule? [2 marks] (i) Before using Gaussian Elimination to achieve triangle form when solving a system of simultaneous equations, what step or steps can be taken to ensure numerical stability? [4 marks] (iii) What is meant by backwards stability regarding a numerical method?

 


6 Numerical Methods (a) A lander for the planet Mars has initial mass M0 = m(0) kilograms which includes F0 = f(0) kilograms of fuel. It is released from an orbiter at time zero at height H0 = h(0) with an initial downwards velocity of zero. It must touch down at less than 1 metre per second. Its downward force is Mg (where g is constant) and this is countered by a rocket motor that is pre-programmed to generate a time-varying upwards force of u(t). The motor burns fuel at a mass rate proportional to the force it develops. This is summarised in these equations: dm(t) dt = u(t) dv(t) dt = u(t) gm(t) m(t) dh(t) dt = v(t) A discrete-time computer simulation of the landing uses time steps t. Using a programming language of your choice or pseudo code: (i) Give a suitable state vector for the system. Include setup code that suitably initialises the state vector. [1 mark] (ii) Give state update assignments for one time step based on simple linear projections assuming a function u(t) has been provided. [2 marks] (iii) Give code for the various stopping conditions. These include a safe landing, a fatal crash or running out of fuel. [1 mark] (iv) Why does a simple linear projection lead to a velocity modelling error in every time step. magnitude and does it compound over successive steps? [3 marks] (b) (i) Briefly describe the bisection method (binary chop) for finding a root of an equation. Mention two possible stopping conditions. [3 marks] (ii) Recall that the CORDIC algorithm uses successive approximation where the ith division of the interval is by arctan(2i ). Give a stopping condition for CORDIC. [2 marks] (iii) The following approximation can be used for cosine: cos(x) 1 x 2 2 . Does it accurately deliver three significant decimal digits where the argument range is 0.0 to /4 ? [2 marks] (iv) Approximately how many iterations of CORDIC are required to ensure three significant decimal digits are accurate over the same range?


Algorithms (a) Consider the radix sort algorithm. (i) Explain how radix sort works, to what inputs it can be applied and what its asymptotic complexity is. [5 marks] (ii) Explain why running radix sort does not proceed from most to least significant digit, as would at first seem more intuitive. [4 marks] (iii) Give a proof by induction of the correctness of radix sort. [4 marks] (b) Clearly describe an algorithm, strictly better than O(n 2 ), that takes a positive integer s and a set A of n positive integers and returns a Boolean answer to the question whether there exist two distinct elements of A whose sum is exactly s. Evaluate its complexity.


a Programmer-Defined Class in Java Summary In this lab, you will a programmer-defined class and then use it in a Java program. The program should create two Rectangle objects and find their area and perimeter. Instructions Make sure the class file named Rectangle.java is open. In the Rectangle class, create two private attributes named lengthand width. Both length and width should be data type double. W public set methods to set the values for length and width. Write public get methods to retrieve the values for length and width. Write a public calculateArea Omethod and a public calculate Perimeter) method to calculate and return the area of the rectangle and the perimeter of the rectangle. Open the file named MyRectangleClassProgramjava. In the MyRectangleClassProgram class, create two Rectangle objects named rectangle1 and rectanglez Set the lengthof rectangle1 to 10.0and the width to 5.0. Set the length of ectangle2 to 7.0 ridthto

Print the value of rectangle1's perimeter and area, and then print the value of rectangle2's perimeter and area. Execute the program. MYRECTANGLECLASSPROGRAM.JAVA class Rectangle /Length of this rectangle. I/ Width of this rectangle. I/ Write set methods here. //Write get methods here. //Write the calculatePerimeter0 and

// Write the calculatePerimeter0 and I/ calculateArea) methods here. RECTANGLE.JAVA -lass Rectangle //Length of this rectangle. I/Width of this rectangle. /Write set methods here. I/Write get methods here.




View the example video to see how your program should run (Doesn't have to be exactly the same but should be similar). See example video Download the supplied starter project: See download link Extract the project from the zip file to a location on your hard drive. (I recommend a location like Documents/FullSail/DES1/Assignments). Do not use generic types or LINQ commands - the point of this assignment is to show that you understand arrays and how to use data stored in them. Deck class: constructors Default: Parameters None Overloaded constructor: Parameters Int: this value represents the desired number of cards in the deck and should be used to initialize the deck's array of PlayingCards to hold that number of cards. Create public methods static void FillDeckWithPlayingCards Parameters Deck: this is the deck object that is to be filled with cards Function If the deck passed in cannot hold 52 cards - initialize the array to hold 52 cards. fill the deck with each card ace-king for each suit (hearts, clubs ...) void DisplayDeck Parameters Int: required parameter that specifies how many cards draw in a row before starting a new row Int: optional parameter that specifies a x position on the screen to start drawing cards at Int: optional parameter that specifies a y position on the screen to start drawing cards at Function Draw ever card in the deck 1 at a time going across the screen in rows. Drop down to a make a new row after x cards where x is the number passed in as the first parameter void AddCard Parameters PlayingCard: card that should be added into the deck Function if the deck isn't full then add the passed in card on top as the next card to be drawn. void Shuffle Parameters None Function This method will randomize the position of all of the cards in the deck PlayingCard DrawCard Parameters None Function This method will remove the top card from the deck and return that card assuming the deck isn't empty void CutDeck Parameters Int: optional parameter that specifies where to cut the deck (number of cards to take off of the top of the deck). Should default to a value of -1. Function If the parameter is a positive value then cut that many cards off the top of the deck. if the parameter is negative then cut a random number of cards off the top of the deck must handle players trying to cut more cards than are in the deck. Program: C a menu in main that will allow the player to test the following deck options. (This menu should run in a loop until the player chooses to quit) Fill the deck with playing cards Shuffle the cards in the deck Cut a random number of cards from the top of the deck Cut a number of cards from the top of the deck specified by the player (required input from the player) Display all of the cards in the deck Quit quit by selecting the menu options (the number) quit by typing "quit" quit by typing "exit" The player should not be able to crash the program with invalid input


Cr a Programmer-Defined Class in Java Summary In this lab, you will c a programmer-defined class and then use it in a Java program. The program should create two Rectangle objects and find their area and perimeter. Instructions Make sure the class file named Rectangle.java is open. In the Rectangle class, create two private attributes named lengthand width. Both length and width should be data type dpublic set methods to set the values for length and width. Write public get methods to retrieve the values for length and width. Write a public calculateArea Omethod and a public calculate Perimeter) method to calculate and return the area of the rectangle and the perimeter of the rectangle. Open the file named MyRectangleClassProgramjava. In the MyRectangleClassProgram class, create two Rectangle objects named rectangle1 and rectanglez Set the lengthof rectangle1 to 10.0and the width to 5.0. Set the length of ectangle2 to 7.0 ridthto


Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Principles of Economics

Authors: Tyler Cowen, Alex Tabarrok

3rd edition

1429278390, 978-1429278416, 1429278412, 978-1429278393

More Books

Students also viewed these Computer Network questions

Question

Can someone help me with the post closing trial balance please

Answered: 1 week ago