Question

Assignment 3 In this assignment, you will write a program that plot ASCII text approximations of...

Assignment 3

In this assignment, you will write a program that plot ASCII text approximations of the Mandelbrot set. Problems Problem 1 Consider the function ?(?,?) defined as follows: ?(?,?)(?, ?) = (?2 − ?2 + ?, 2?? + ?) We define the orbit ?(?, ?) of a point (?, ?) to be an infinite list of items: ?(?, ?) = {(0, 0), ?(?,?)(0, 0), ?(?,?)(?(?,?)(0, 0)), ?(?,?)(?(?,?)(?(?,?)(0, 0))), …} In other words, the nth entry of the list ?(?, ?) is the ?(?,?) function composed with itself n times and then applied to (0, 0). Define a F# function orbit that takes a single point (?, ?) and index ? as an arguments and returns an ? ?ℎ element of the infinite list corresponding to ?(?, ?). • You may want to define a helper function corresponding to ?(?,?).

2)Problem 2 Define a recursive function disp that takes two arguments: • a number d, and • a list of tuples pairs. Every tuple in this input list consists of a number followed by a character, and you can assume the input list is always in ascending order. For example, a possible input list might be: [(0.15, '#'), (0.5, 'x'), (1.0, '.')] The function disp should return the character from the list that corresponds to the smallest number on the list that is greater than the input d, and if d is larger than all the number in the list, disp should return a space character, ’ ’.

For example, 1

disp 0.01 [(0.15, '#'), (0.5, 'x'), (1.0, '.')] = '#' disp 0.4 [(0.15, '#'), (0.5, 'x'), (1.0, '.')] = 'x' disp 100 [(0.15, '#'), (0.5, 'x'), (1.0, '.')] = ' '

Problem 3 One way to approximate the Mandelbrot set is to consider a certain element within the orbit of every point on the plane (such as the 12th element) and to check whether that element is within a a certain distance from the origin; if it is within this distance, then a non-blank character should be printed, else it should be left blank. You should use the following function to calculate distances of points from the origin: let norm (x,y) = x*x + y*y These distance values can then be used with disp and orbit to turn points on the plane into appropriate ASCII characters within an ASCII plot of the Mandelbrot set. Define a function mandelbrot that takes three arguments: • the resolution of the approximation, r (used with the plane function), • the index of the elements, i, to check in the orbit lists of the points, and • the formatting list, l (to be used with the disp function). This function should return a list of characters that corresponds to a picture approximating the shape of the Mandelbrot set on the plane. You will need to combine the split, plane, disp, and orbit functions appropriately; list comprehensions are allowed. Once you’ve defined the function mandelbrot, you can generate an ASCII version of an approximation of the Mandelbrot set by evaluating the expression: mandelbrot 17 12 disp_symbols |> printfn "%s";;

Fill the missing parts of the functions (see below)

Driver Source Core let disp_symbols = [(0.15, '#'); (0.5, 'x'); (1.0, '.')];; let str chs = List.fold (fun str x -> str + x.ToString()) "" chs;; let plane r = [ for y in -1.0 .. 1.0/r .. 1.0 do for x in -2.0 .. 1.0/r .. 1.0 do yield (x, y) ];; let norm (x,y) :float = x*x + y*y;; let split n ch xs = ... let rec orbit (x,y) i = ... let disp xs (d:float) = ... let mandelbrot r i = ... // Example of the function call mandelbrot 17 12 |> printfn "%s";;

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Assignment 3 In this assignment, you will write a program that plot ASCII text approximations of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Write a program that replace repeated three characters in a string by the character followed by 3...

    Write a program that replace repeated three characters in a string by the character followed by 3. For example, the string aabccccaaabbbbcc would become aabc3ca3b3cc. When there are more than three repeated characters, the first three characters will be replaced by the character followed by 3. You can assume the string has only lowercase letters (a-z). Your program should include the following function: void replace(char *str, char *replaced); Your program should include the following function: void replace(char *str, char *replaced);...

  • In basic c develop the code below: (a) You will write a program that will do...

    In basic c develop the code below: (a) You will write a program that will do the following: prompt the user enter characters from the keyboard, you will read the characters until reading the letter ‘X’ You will compute statistics concerning the type of characters entered. In this lab we will use a while loop. We will read characters from stdin until we read the character ‘X’. Example input mJ0*5/]+x1@3qcxX The ‘X’ should not be included when computing the statistics...

  • C programming 1) When setting a two-dimensional character array, how is the size (number of characters)...

    C programming 1) When setting a two-dimensional character array, how is the size (number of characters) in the second dimension set? Select an answer: The number of elements are equal to the average size of all the strings. To the length of the longest string; you don't need to add one because the first array element is zero. To the length of the longest string, plus one for the null character. The second dimension is equal to the number of...

  • 6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you...

    6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you will practice working with arrays. Your program will read lines of text from the keyboard and use an array to track the number of times each letter occurs in the input text. You will use the contents of this array to generate a histogram (bar graph) indicating the relative frequencies of each letter entered. Test cases are available in this document. Remember, in addition...

  • STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop...

    STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...

  • STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop...

    STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...

  • (a) Write a C program to print a list of all integers between 1 and 1,000...

    (a) Write a C program to print a list of all integers between 1 and 1,000 (inclusive) which are divisible by 7 but not by 13. The list should be printed to a file called "output.dat". Remember to close the file after use. (35%) (b) Explain what is meant by the C preprocessor. Explain the effect of the following line of code: #define SQUARE (x) (x) * (x) (25%) (c) Explain the concept of an array in C. Write down...

  •    Problem 2: Sequence similarity measure. Let 3 and y be two given DNA sequences, represented...

       Problem 2: Sequence similarity measure. Let 3 and y be two given DNA sequences, represented as strings with characters in the set {A, G, C,T}. The similarity measure of r and y is defined as the maximum score of any alignment of r and y, where the score for an alignment is computed by adding substitution score and deletion and insertion scores, as explained below. (Some operations have negative scores.) The score for changing a character T, into a...

  • PLEASE USE F# PROGRAMMING LANGUAGE: NO LOOPS OR CORE LIBRARY FUNCTIONS. ONLY USE RECURSION. Problem 3...

    PLEASE USE F# PROGRAMMING LANGUAGE: NO LOOPS OR CORE LIBRARY FUNCTIONS. ONLY USE RECURSION. Problem 3 (10 pts) Define a function rev that takes a list xs and returns it in the reverse order. • F# standard library has List.rev, do not use it. You need to reimplement it. In [ ]: let rev (xs: 'a list) In [ ]: // Test you function List.rev [] = rev [] |> printfn "%" List.rev [1..9] = rev [1..9] |> printfn "%b'...

  • C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show...

    C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show super and sub class relationships with an array of super media pointers to sub class objects and dynamic binding. The < operator will be overloaded in the super class so all subclasses can use it. The selection sort method will be in the main .cpp file because it will sort the array created in main. The final .cpp file, the three .h header class...

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