Giter Club home page Giter Club logo

system-solver's Introduction

System-Solver

Table of Contents

Setup

  • First of all: you must install the Front-End folder which contains angular project, using npm install just because node modules may be missing.
  • Secondly: Spring Boot folder is straight forward just open the pom file using any IDE.
  • Thirdly: you run the Angular project and on localhost:4200 and the Spring Boot project on localhost:8080.

Description

The project was divided into two parts:

  1. the first part's objective is to solve systems of linear equations using various direct and iterative methods, namely:
  • Gauss Elimination.
  • Gauss Jordan.
  • LU Decomposition (using Crout’s, Doolittle, and Cholesky Decompositions).
  • Gauss Seidil.
  • Jacobi Iteration.
  1. the second part's objective is to extend the project’s functionality to include the capability of finding the roots of linear and non-linear functions using:
  • Bisection.
  • False-Position.
  • Fixed point.
  • Newton-Raphson.
  • Secant Method.

Design Decisions

Part One:

  • This part was chosen to be written as a web application using a MVC architecture so that it can be used on any platform. The backend is written in Java using Spring framework, and the frontend is written in TypeScript using Angular

Part Two:

  • This part does not use the same architecture as the previous phase, instead, all of the computations are done in client-side to make use of the MathJs library as it is used in finding the derivative of the inputted functions.

PseudoCode for the Main Algorithms

Part One:

solveIterative(guess, maxIterations, tolerance, applyGaussSeidel):
if(maxIterations == 0):
return guess
newGuess = iterate(guess, applyGaussSeidel)
if(getError(newGuess) < tolerance):
return newGuess
return solveIterative(newGuess, maxIterations1, tolerance, 
applyGaussSeidel)
GaussElimination(Jordan, shouldPivot, shouldSolve):
for i: 1 -> rows:
if(shouldPivot):
applyPivoting(i)
if(pivot == 0):
return noUniqueSolution();
if(Jordan):
j = 1
else:
j = i+1
for j: j -> rows:
performRowOperation(i, j);
if(shouldSolve)
return backSub(System)
return coeff //After row operations
dooLittleDecomposition(coeff, constant):
Solver solver = new Solver(coeff, constant)
solver.GaussElimination(Jordan = false, shouldPivot = false, shouldSolve = 
false)
lower = solver.getScale() //Scale[i][j] is the multiplier used in 
rowOperation(i,j)
for i: 1 -> rows:
lower[i][i] = 1
upper = solver.getCoeff()
return {lower, upper}
choleskyDecomposition(coeff, constant):
Solver solver = new Solver(coeff, constant)
solver.GaussElimination(Jordan = false, shouldPivot = false, shouldSolve = 
false)
for i: 1 -> rows:
for j: 1 -> i:
sum = 0
for k: 1 -> j-1:
sum+= lower[i][k]*lower[j][k]
lower[i][j] = coeff[i][j] – sum 
if(i == j):
lower[i][j] = sqrt(lower[i][j])
else:
lower[i][j] /= lower[j][j]
upper = lower.transpose()
return {lower, upper}
croutDecomposition(coeff, constant):
Solver solver = new Solver(coeff, constant)
solver.GaussElimination(Jordan = false, shouldPivot = false, shouldSolve = 
false)
for i: 1 -> rows:
upper[i][i] = 1
for j: 1 -> rows:
 for i: j -> rows
 sum = 0
 for k: 1 -> j-1:
 sum += lower[i][k]*upper[k][j]
 lower[i][j] = coeff[i][j] – sum
 for i: j -> rows:
 sum = 0
 for k: 1 -> j-1:
 sum += lower[j][k] * upper[k][i];
 upper[j][i] == (coeff[j][i] – sum)/lower[j][j];
return {lower, upper};

Part Two:

applyBisection():
while(abs(xuxl) > eps && iteration_counter < maxIterations):
xr = precise((xl + xu)/2), fr = substitute(xr), fl = substitute(xl)
if(fl * fr > 0):
xl = xr
else:
xu = xr
steps.push(iteration_counter, xl, xu, fr, abs(xuxl))
if(fr == 0):
break;
iteration_counter++
return xr
applyFalsePosition():
while(abs(xuxl) > eps && iteration_counter < maxIterations):
fu = substitute(xu), fl = substitute(xl)
 xr = precise(xufu*(xu-xl)/(fu-fl)), fr = substitute(xr)
if(fl * fr > 0):
xl = xr
else:
xu = xr
steps.push(iteration_counter, xl, xu, fr, abs(xuxl))
if(fr == 0):
break;
iteration_counter++
return xr
applyFixedPoint():
setGX()
do:
xi = xi1
xi1 = substituteGX(xi)
steps.push(iteration_counter+1, xi, substitute(xi), abs(xixi1)}
iteration_counter++
while(abs(xixi1)>eps && iteration_counter < maxIterations)
return xi1
applyNewtonRaphson():
derivativeNode = MathJs.derivative(getExpression(), ‘x’)
do:
xi = xi1
fxi = substitute(xi)
 dfxi = precise(derivativeNode.evaluate(xi))
xi1 = precise(xifxi/dfxi)
steps.push(iteration_counter+1, xi, fxi, abs(xixi1)}
iteration_counter++
while(abs(xixi1)>eps && iteration_counter < maxIterations)
return xi1
applySecant():
while(abs(xCurrxPrev)>eps && iteration_counter < maxIterations):
fprev = substitute(xPrev), fcurr = substitute(xCurr)
xTemp = precise(xCurrfcurr*(xCurr-xPrev)/(fcurr-fprev))
steps.push(iteration_counter+1, xTemp, xPrev, xCurr, 
substitute(xTemp), abs(xCurrxPrev))
iteration_counter++
return xCurr

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.