Term Project
Uni: MIREA – Russian Technological University
Field of study: Applied Mathematics and Informatics, Master's Degree
Subject: Functional Programming
- Programming Language:
Swift - Use some fuctional programing patterns:
closures,pure finctions,higher-order functions(i.e. map, filter, reduce),etc.
>f1(x) = x^2
f1(x) = x^2
>f2(x) = 3*x
f2(x) = 3*x
>f1(x) = x^2
f1(x) = x^2
>f2(x) = 3*x
f2(x) = 3*x
>f3(x) = f1(x) + f2(x)
f3(x) = x^2 + 3*x
>f3(x) = x^2 + 3*x
f3(x) = x^2 + 3*x
>f3(10)
f3(10) = 130
>f3(x) = x^2 + 3*x
f3(x) = x^2 + 3*x
>f3’
f3’(x) = 2x + 3
- Get rid of all spaces inside entered string
- Write regular expressions to indentify command type (expression
f1(x) = x^2, calculationf3(10)or invalid) - Parse expression-commands via regex and save results to Dictionary, where key is a name of a function (e.g.
f) and value is struct containing symbol (e.g.x) and mathematical expression (e.g.x^2 + 3*x). So f(x) will overwrite f(y) and that's good, because when we calculate the function value, we don't use any symbol, only function name:f(10) - Transform functions defined by previosly defined functions into original representation (e.g.
f1(x) + f2(x)->x^2 + 3*x) - Do research into sumbolic derivation techniques
- Study Shunting_yard algorithm to translate
Infix notationtoReverse Polish Notation - Implement Stack data structure
- Check for parentheses balance
- Detect numbers with many digits and decimal point as single token
- Replace symbol of function (e.g. 'x' in 'f(x)') with number while function value calculation (e.g. 'f(10)') before using Shunting_yard algorithm
- Implement token detection
- Implement Shunting_yard algorithm
- Implement Expression Tree creation from Postfix Notation
- Implement evaluation of Expression Tree
- Implement symbolic differentiation
- Refactor