# Project 2

## Project description

### Project

In mathematics, we use superpositions of functions often. Say we have two functions $$f: R \rightarrow R$$ and $$g: R \rightarrow R$$, we defined superposition as $$(g \circ f)(x) = g(f(x))$$. That is, we first compute $$y = f(x)$$ and then $$g(y)$$. Obviously, we can define superpositions of any number (finite in this project) of functions, e.g., $$(h \circ g \circ f)(x)$$. The project is about defining superposition binary operator %@%.

sin %@% -pi/4


[1] -3.061617e-17


The above expression returns the value $$\sin(-\pi/4)$$ when evaluated. My implementation of the %@% operator allows for superposing any finite number of functions like in the following example.

abs %@% sin %@% -pi/4
exp %@% abs %@% sin %@% -pi/4
tanh %@% exp %@% abs %@% sin %@% -pi/4


[1] 3.061617e-17
[1] 0.25
[1] 0.1903985


The above expressions define the following functions $$\left| sin(-\pi/4)\right|$$, $$e^{\left| sin(-\pi/4)\right|}{}$$, and $$\tanh(e^{\left| sin(-\pi/4)\right|})$$, respectively. Note that the flow of computations goes from right to left, as in mathematics, and not from left to right, as is standard in R.

### Technical conditions

The project should be solved in a single R file. The file should contain the solution (implementation) and examples of use (you can use the above examples). Solutions without examples will not be excepted. You are not allowed to use any additional packages. Please, do not use polish diacritics.

Date: 2021-05-03 Mon 00:00

Created: 2021-05-04 Tue 10:19

Validate