Giter VIP home page Giter VIP logo

funccalc's Introduction

FuncCalc

Term Project

Uni: MIREA – Russian Technological University

Field of study: Applied Mathematics and Informatics, Master's Degree

Subject: Functional Programming

Requirements

Non-functional requirements

  • Programming Language: Swift
  • Use some fuctional programing patterns: closures, pure finctions, higher-order functions (i.e. map, filter, reduce), etc.

Functional requirements

Defining functions with numbers and simple arithmetic operations (+, -, *, /, ^) in infix notation

>f1(x) = x^2
f1(x) = x^2

>f2(x) = 3*x
f2(x) = 3*x

Defining functions via previosly defined functions

>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

Calculation of the function value

>f3(x) = x^2 + 3*x
f3(x) = x^2 + 3*x

>f3(10)
f3(10) = 130

Taking symbolic derivative

>f3(x) = x^2 + 3*x
f3(x) = x^2 + 3*x

>f3’
f3’(x) = 2x + 3

Tasks to accomplish functional requirements

  • Get rid of all spaces inside entered string
  • Write regular expressions to indentify command type (expression f1(x) = x^2, calculation f3(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 notation to Reverse 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.