Question

MATH 3421 Maple Assignment 1 Due February 13, 2019 Maple is a Computer Algebra System that...

MATH 3421 Maple Assignment 1 Due February 13, 2019 Maple is a Computer Algebra System that is able to do some of the algebraic calculations of mathematics. Maple also allows you to present nicely-formatted mathematics! The purpose of this assignment is to remind you of Maple’s capabilities. Ground Rules 1. Your assignment must have a properly-formatted title identifying the assignment number and course. There must be an “author.” There must be other text with properly-formatted math included. 2. Your assignment must be as a Worksheet, not a Document, and commands must be in Maple notation, not 2-D Display. 3. Load all packages at the top of the worksheet, just below the title. 4. Lines whose output you do not want to see must end with a “:” 5. Object names must be descriptive. “f1” is a very bad choice for an object name, especially if you define many functions. 6. When naming an object, “:=” has a space before and a space after. Commas must be followed by a space. 7. Comment your code! If you are commenting the code itself, use an inline code comment, (command line starting with a “#”), but if it is a comment on your math, it must be in Text Mode. 8. Late assignments lose 10% per day. 9. All graphs must be black-and-white. If they have more than one plot, different line styles must be used to distinguish the plots, and there must be a legend. 10. Eliminate unnecessary blank lines (Ctrl-Delete). Assignment 1.

question1: The function f(x) ={x^2 sin(1/x) if x is not equal to zero and 0 if x is zero} has an interesting feature at 0. (a) Plot f(x) over some reasonably small interval that contains 0. (b) Find the derivative of x^2 sin( 1 /x) , and find the limit of the derivative as x → 0. Remember that a limit must be a single value, not a range of values. (c) Plot the derivative. Is the result of the previous part surprising? (d) Use the definition of derivative to find the derivative of f at 0, that is, take the limit of the difference quotient using Maple. (e) Comment on what you have found.

question 2. We will solve two differential equations that look similar but lead to very different-looking solutions. We will then plot those solutions. (a) Use dsolve to solve dy /dx = (1−y)^2, y(0) = 0.8, and dy /dx = (1.01−y)(1−y), y(0) = 0.8. All Maple DE commands like the dependence of dependent variables made explicit in the DE (y(x), not y). (b) Plot both solutions on the same graph. The solutions from the previous part will be equations, which Maple will refuse to plot. Use rhs to extract the right-hand side of each equation. Make sure they have either different colours or different linestyles, and make sure your graph has a legend and title. (c) Comment on the two solutions and their graphs, and make sure your conclusion includes properly formatted math.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts. Also a word of advice: in future, when posting another question, please split these kinds of problems into multiple questions. They are big enough to be single questions. Also there is difficulty while submitting answers. Thanks

Answer for part 1 (a2a)

// PartA.java

import java.io.File;

import java.io.FileNotFoundException;

import java.io.PrintWriter;

import java.util.HashMap;

import java.util.Iterator;

import java.util.Map;

import java.util.Scanner;

public class PartA {

                static HashMap<String, Integer> medalsbyCountries;

                static HashMap<String, Integer> medalsbyEvents;

                /**

                * method to read the input file and fill the hashmaps

                * @param filename- input file name

                * @throws FileNotFoundException - if file not found

                */

                static void readFile(String filename) throws FileNotFoundException {

                                medalsbyCountries = new HashMap<String, Integer>();

                                medalsbyEvents = new HashMap<String, Integer>();

                                Scanner scanner = new Scanner(new File(filename));

                                /**

                                * looping through the file

                                */

                                while (scanner.hasNext()) {

                                                /**

                                                * getting country and event names

                                                */

                                                String country = scanner.nextLine();

                                                String eventType = scanner.nextLine();

                                                String specificEvent = scanner.nextLine();

                                                /**

                                                * Adding to the maps of countries and medals, if not already exists

                                                */

                                                if (!medalsbyCountries.containsKey(country)) {

                                                                medalsbyCountries.put(country, 1);

                                                } else {

                                                                /**

                                                                * updating the medals if country exists

                                                                */

                                                                int medals = medalsbyCountries.get(country);

                                                                medals++;

                                                                medalsbyCountries.put(country, medals);

                                                }

                                                /**

                                                * Adding to the maps of event types and medals, if not already exists

                                                */

                                                if (!medalsbyEvents.containsKey(eventType)) {

                                                                medalsbyEvents.put(eventType, 1);

                                                } else {

                                                                /**

                                                                * updating the medals if event type exists

                                                                */

                                                                int medals = medalsbyEvents.get(eventType);

                                                                medals++;

                                                                medalsbyEvents.put(eventType, medals);

                                                }

                                }

                }

                /**

                * method to display and save the results from the hashmaps

                * @throws FileNotFoundException- if output file cannot be created

                */

                static void displayAndSave() throws FileNotFoundException {

                                /**

                                * Defining a PrintWriter for writing to a2q1out.txt file

                                */

                                PrintWriter writer = new PrintWriter(new File("a2q1out.txt"));

                                System.out.println("Count of gold medallists by country:");

                                writer.println("Count of gold medallists by country:");

                                /**

                                * looping through the hashmap

                                */

                                for (Map.Entry<String, Integer> entry : medalsbyCountries.entrySet()) {

                                                System.out.println(entry.getKey() + " - " + entry.getValue());

                                                writer.println(entry.getKey() + " - " + entry.getValue());

                                }

                               

                                System.out.println("Count of gold medallists by event type:");

                                writer.println("Count of gold medallists by event type:");

                                /**

                                * looping through the hashmap

                                */

                                for (Map.Entry<String, Integer> entry : medalsbyEvents.entrySet()) {

                                                System.out.println(entry.getKey() + " - " + entry.getValue());

                                                writer.println(entry.getKey() + " - " + entry.getValue());

                                }

                               

                                writer.close();//closing the writer and saving the file

                }

                public static void main(String[] args) {

                                try {

                                                /**

                                                * Reading the file and displaying the results

                                                */

                                                readFile("a2a.txt");

                                                displayAndSave();

                                } catch (FileNotFoundException e) {

                                                e.printStackTrace();

                                }

                }

}

Answer for part2 (a2b)

// PartB.java

import java.io.File;

import java.io.FileNotFoundException;

import java.util.ArrayList;

import java.util.Scanner;

public class PartB {

                static ArrayList<Sentence> sentences;//array list of sentences

                /**

                * method to read the input file, and fill the sentences array list

                */

                static void readFile(String filename) throws FileNotFoundException {

                                sentences = new ArrayList<Sentence>();

                                Scanner scanner = new Scanner(new File(filename));

                                Sentence sentence = new Sentence();

                                while (scanner.hasNext()) {

                                                String word = scanner.next();

                                                sentence.add(word);

                                                char ending = word.charAt(word.length() - 1);

                                                if (ending == '.' || ending == '!' || ending == '?'

                                                                                || ending == ':' || ending == ';' || !scanner.hasNext()) {

                                                                sentences.add(sentence);

                                                                sentence = new Sentence();

                                                }

                                }

                }

                /**

                * method to print the first and last five sentences

                */

                static void printFirstAndLastFive() {

                                if (sentences != null && sentences.size() >= 5) {

                                                System.out.println("First five sentences: ");

                                                for (int i = 0; i < 5; i++) {

                                                                System.out.println(sentences.get(i).getText());

                                                }

                                                System.out.println(" Last five sentences: ");

                                                for (int i = sentences.size() - 1; i >= sentences.size() - 5; i--) {

                                                                System.out.println(sentences.get(i).getText());

                                                }

                                }

                }

                /**

                * method to analyze and print the stats

                */

                static void analyzeStats() {

                                int totalWords = 0, totalLetters = 0;

                                int totalSentences = sentences.size();

                                for (Sentence s : sentences) {

                                                //finding total words and letters

                                                totalWords += s.getWordCount();

                                                totalLetters += s.getLettersCount();

                                }

                                System.out.println(" Summary statistics");

                                System.out.println("Letters: " + totalLetters);

                                System.out.println("Words: " + totalWords);

                                System.out.println("Sentences: " + totalSentences);

                                double lettersByWords = (double) totalLetters / totalWords;

                                double wordsBySentences = (double) totalWords / totalSentences;

                                double ARI = 4.71 * lettersByWords + 0.5 * wordsBySentences - 21.43;

                                System.out.println("Readability: "+ARI);

                }

               

                public static void main(String[] args) {

                                try {

                                                /**

                                                * reading and displaying the stats

                                                */

                                                readFile("a2b.txt");

                                                printFirstAndLastFive();

                                                analyzeStats();

                                } catch (FileNotFoundException e) {

                                                e.printStackTrace();

                                }

                               

                }

}

//Sentence.java

public class Sentence {

                private String text;

                private int wordCount;

                private int lettersCount;

               

                public Sentence() {

                                text="";

                                wordCount=0;

                                lettersCount=0;

                }

                public void add(String word){

                                text+=word+" ";

                                wordCount++;

                                /**

                                * Reading letters count

                                */

                                for(int i=0;i<word.length();i++){

                                                if(Character.isLetter(word.charAt(i))){

                                                                lettersCount++;

                                                }

                                }

                }

                public String getText() {

                                return text;

                }

                public int getLettersCount() {

                                return lettersCount;

                }

                public int getWordCount() {

                                return wordCount;

                }

}

/*OUTPUT part 1 (partial)*/

/*OUTPUT part 2 (partial)*/

Add a comment
Know the answer?
Add Answer to:
MATH 3421 Maple Assignment 1 Due February 13, 2019 Maple is a Computer Algebra System that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  •    MATLAB SCRIPT PLEASE Matlab MATH 210 in 2020 Homework Assignment 8- Due 3/25, 11:59PM Each...

       MATLAB SCRIPT PLEASE Matlab MATH 210 in 2020 Homework Assignment 8- Due 3/25, 11:59PM Each plot should have its own figure associated with it. In all questions, give the figure a title, and label the acis. Save your matlab script as drill 10.m Do not use the fplot command. 1. Plot the function f(x) = (x + 5)2 for -5 <<<10. Include a plot title, and label both aris. 2. Use the subplot command to make two plots of...

  • Math 2413 Derivative Applications Assignment Due: Tuesday, June 18, 2019 (5:30 pm) Name Show all work....

    Math 2413 Derivative Applications Assignment Due: Tuesday, June 18, 2019 (5:30 pm) Name Show all work. Label your answers with the proper units. (3 points each ) A spherical ball is being inflated at the rate of 12 cubic inches per second. Find the rate at which the radius of the sphere is growing when the radius is 2 inches. long. 2. A 13 foot ladder is leaning against a wall. The base of the ladder is being palled away...

  • ECE 270 Computer Methods in ECE OnLine Quiz #5 June 4, 2019/Instructor: Paul Watta 1. Math Analysis. Given the foll...

    ECE 270 Computer Methods in ECE OnLine Quiz #5 June 4, 2019/Instructor: Paul Watta 1. Math Analysis. Given the following sequence operation, please do a mathematical analysis as outlined on page 1 of the Sequence and Array Operations notes (parts a - d). Insert Subsequence. The sequence y has all of the elements of x along with an inserted subsequence: Po Po... Pm-1. Let k be the index where the insert occurs. 2. Programming. Write a program to implement the...

  • Differential Equations Project - must be completed in Maple 2018 program NEED ALL PARTS OF THE PR...

    Differential Equations Project - must be completed in Maple 2018 program NEED ALL PARTS OF THE PROJECT (A - F) In this Maple lab you learn the Maple commands for computing Laplace transforms and inverse Laplace transforms, and using them to solve initial value problems. A. Quite simply, the calling sequence for taking the Laplace transform of a function f(t) and expressing it as a function of a new variable s is laplace(f(t),t,s) . The command for computing the inverse...

  • Computer Science

    https://coastwatch.glerl.noaa.gov/ftp/glsea/avgtemps/2020/glsea-temps2020_1024.datIt is up to you to extract the data from the file and put it into MATLAB. This operation must be done with MATLAB! Do not copy and enter data by hand! You are to make a report showing tables, graphs and conclusions based on data using MATLAB functionality. Required elements: The entire project must be presented as one single script file . Divide your codes into sections, one for each question, and add text comments to identify which question...

  • Assignment 1: Bivariate Regression ECO 321 DUE Thursday, February 20 at the beginning of class. You...

    Assignment 1: Bivariate Regression ECO 321 DUE Thursday, February 20 at the beginning of class. You must submit a hard copy of the assignment. 1. Consider the standard bivariate regression Y B + B,X, + a) Suppose that we estimate the above function using a sample of data and the ordinary least square method (OLS). Write down the sample regression function b) Name each of the components in part (a). Then graph an example of the function along with some...

  • Programming Assignment 3 CSCI 251, Fall 2015 Infinite Series Trigonometric and math functions are...

    Programming Assignment 3 CSCI 251, Fall 2015 Infinite Series Trigonometric and math functions are usually calculated on computers using truncated Taylor series (an infinite series). An infinite series is an infinite set of terms whose sum is a particular function or expression. For example, the infinite series used to evaluate the natural log of a number is (x - 1)2 (x-1)3 (x-1)* (x-1)5 2 4 where x E (0, 2], or 0

  • Need help with this Matlab program %% Exercise 1 % NOTE: Please suppress output--i.e., use a...

    Need help with this Matlab program %% Exercise 1 % NOTE: Please suppress output--i.e., use a semicolon ';' at the end of any % commands for which the output is not necessary to answer the question. % Delete these notes before turning in. % Define input variable theta as discretized row vector (i.e., array). theta = ??; % Define radius. r = ??; % Define x and y in terms of theta and r. x = ??; y = ??;...

  • I need help with the matlab code, thank you. The purpose of this assignment is to...

    I need help with the matlab code, thank you. The purpose of this assignment is to illustrate one important difference between linear and nonlinear models of oscillating systems. In an undamped, unforced linear system, the period of a periodic solution depends only on system parameters and not on the initial conditions, but in a nonlinear system the period can depend on the initial conditions Consider the following nonlinear differential equation, which models the free, undamped motion of a block attached...

  • Update the program in the bottom using C++ to fit the requirements specified in the assignment....

    Update the program in the bottom using C++ to fit the requirements specified in the assignment. Description For this assignment, you will be writing a single program that enters a loop in which each iteration prompts the user for two, single-line inputs. If the text of either one of the inputs is “quit”, the program should immediately exit. If “quit” is not found, each of these lines of input will be treated as a command line to be executed. These...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT