---
# System prepended metadata

title: 'AEP 2: Analyzing functions in your favorite language'
tags: [' aep', ' 225-spr22', mth225]

---

---
tags: mth225, 225-spr22, aep 
---

# AEP 2: Analyzing functions in your favorite language 

## Overview 

In this AEP, you'll extend an activity we did in class where we took some functions and methods from Python and looked at them from the point of view of mathematical functions. Here, you'll do the same, except pick a range of functions from your favorite programming language. 

:::warning
**Deadline**: This AEP should be submitted on or before **Sunday, June 5 at 11:59pm ET**. If you need an extension on this deadline, contact the professor and explain why you need the extension, and when you plan on turning in the work. 
:::


## Background

In a recent class meeting, we did an activity where we took some Python string functions and thought of them like mathematical functions, and determined 

+ The domain and codomain of the function;  
+ Whether the function is injective, surjective, neither, or both (bijective), and how we know; and
+ What all of this information might mean on a practical level. 

For example, we looked at the `len` function in Python which takes in a string and returns its length. Here is a summary of what we learned about it: 

* The domain of this function is the set of all Python strings, and the codomain can be thought of as either $\mathbb{N}$ or $\mathbb{Z}$. Both are correct from a mathematical standpoint, but $\mathbb{Z}$ is a little more appropriate from a computer science standpoint since the codomain typically represents the *data type* of the output, and `len` produces `Integer` output. There is no "natural number" data type in Python. 
* The `len` function is not injective because any two strings with the same length will collide, for example `len('foo') = len('bar')`. 
* The `len` function is not surjective if you take the codomain to be $\mathbb{Z}$, because there are no strings that would map to a negative length. But if you felt like the codomain was $\mathbb{N}$, then `len` *is* surjective, because given any natural number $n$ that is in the codomain, we can find a string that maps to it. For example if `my_text` is a string consisting of $n$ copies of the letter `A`, then `len(my_text) = n`. 
* What this means on a practical level: There could be a variety of implications of all this. For example, noticing that the codomain of `len` is $\mathbb{Z}$ (or at least, is a subset of $\mathbb{Z}$) means that we cannot compose `len` with any function that doesn't accept integers as input. 

This way of analyzing computer functions by treating them like mathematical functions can really help understand the details of how those functions work. Since computer languages are basically nothing but thousands of functions, there's lots to analyze! 

 
## Tasks for this AEP

1. Pick a language that you know, or would be willing to learn a little about. Then go to that language and find **eight (8) functions or methods** that are used by that language (perhaps in a library that you would load). 
2. For **each** of those ten functions or methods, **do the following:** 
    (a) Explain in very basic terms what the function does. Remember that your audience (especially the professor!) may not know the language, so you'll need to explain as if to a smart middle school student. For that reason, you should avoid extremely technical or obscure functions; stick to the basics and keep it simple. 
    (b) Determine what the domain and codomain of the function are, and explain your reasoning. 
    (c) Determine whether the function is injective, surjective, neither, or both (bijective) and explain your reasoning. See "Note on explaining your reasoning" below. 
    (d) Explain what all of the information above might mean for a programmer trying to write code to solve a problem. For example, does a failure of being injective cause any potential issues with errors or security? Does having a particular domain or codomain open up possibilities of combining the function with something else, to do something cool? Use your imagination! 

:::info
**Note on explaining your reasoning:** The main criteria used for evaluating your work on this and most other AEPs is the *quality of your explanations, not the correctness of your answers*. It's pretty easy to get right answers; but it takes real understanding to explain why they are right. Some pointers for good explanations: 

- **Keep it simple and clear.** Do not assume that the reader is a genius, has lots of experience shared with you, or wants to fill in any gaps you leave. Use plain language and make your explanations as clear as possible. 
- **General statements are not explained by examples.** For example if you think a function is injective, it means that there are no collisions from the input to the output. Explaining this, requires that you explain why collisions **never** happen with this function; a single, specific example of a collision not happening isn't convincing, because perhaps you just cherry-picked a good example to trick us. 
- **Remember the audience**. The audience is your classmates --- people who are smart and have all the background knowledge that a regular person in the class would have, but none of the specialized knowledge that *you* have, and no experience with your particular problem. At regular intervals, stop and ask yourself if, honestly, your explanation would be clear and convincing for that audience. If not, keep polishing it.

::: 
## Expectations and Grading Criteria 

AEPs are graded using the "EMRN" rubric found in the syllabus. Make sure you review the [Standards for Assessments in MTH 225](/KoT83ezHRYO3DqPyXMMMag) document before you submit any work, so you're fully aware of the expectations for the different marks. In particular: 

- All work needs to be shown *and* your thought processes clearly expressed in all of the tasks of the assignment. The results also need to be correct. You are not just doing math; you are explaining things to a reader, so a mix of math and English is needed. 
- All the information needed for an "outsider" to understand your work needs to be self-contained within the work. **The reader should not have to do any work to fill in gaps.** 

Please note, it is the case with all AEP's that **your grade is primarily based on your explanations and writing, and only secondarily on the precision and correctness of your computations.** Correct computations with insufficient explanation will need to be revised and may receive an "N" grade. 

A grade of "E" is given if all of the above expectations are met, and the work is of superior quality in terms of the clarity of explanations and work, appearance of the writeup, and precision of the mathematics. 


## Submitting your work 

**AEP submissions must be typewritten and saved as either a PDF or MS Word file. No part of your submission may involve handwriting; work that is submitted that contains handwriting will be graded N and returned without feedback.** This includes electronic handwritten docments, for example using a stylus and a note-taking app. To type up your work, you can use MS Word or Google Docs (both of which have equation editors for mathematical notation) or any other computer-based math typesetting tool. Just make sure you save your work as a Word document or PDF (no `.odt`, `.rtf`, or other file extensions are allowed).

When you have your work typed up, double-check it for neatness, correctness, and clarity. Then simply submit your document on Blackboard, in the **AEP** area, in the **AEP 2** assignment. 




## Getting Help

You **may** ask me (Talbert) for help on this assignment in the form of **specific mathematical or technical questions, or clarifying questions about the instructions**. If I cannot answer a question because it would give too much away, I'll tell you so. However please note: **I will not "look over your work" before you submit it to give you feedback on the overall submission**. I have made the expectations clear, so just follow those directions and submit your best work, and you'll be allowed to revise it if needed. 

For AEPs, the syllabus policy on collaboration is: 

>**No collaboration is allowed at all** — with other people, or with print or electronic sources other than your textbook, the video playlist, or your notes.
 
**You can ask technology related questions to anyone at any time**. For example if you need help figuring out how to type up your work, there are no restrictions on that. 