#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 11 18:14:35 2019

@author: exame
"""

#Equações de cada variavel
def fx(cx,x,cy,y,cz,z,cw,w,b):
    return (b-(cy*y+cz*z+cw*w))/cx

def fy(cx,x,cy,y,cz,z,cw,w,b):
    return (b-(cx*x+cz*z+cw*w))/cy

def fz(cx,x,cy,y,cz,z,cw,w,b):
    return (b-(cx*x+cy*y+cw*w))/cz

def fw(cx,x,cy,y,cz,z,cw,w,b):
    return (b-(cx*x+cy*y+cz*z))/cw

def gaussSeidel(numItr):
    #valores iniciais (x0)
    x=2.83865
    y=2.22131
    z=4.17630
    w=-3.84236
    for i in range(numItr):
        x=fx(6,x,0.5,y,3,z,0.25,w,25)
        y=fy(1.2,x,3,y,0.25,z,0.2,w,10)
        z=fz(-1,x,0.25,y,4,z,2,w,7)
        w=fw(2,x,4,y,1,z,8,w,-12)
        print("x: ",x)
        print("y: ",y)
        print("z: ",z)
        print("w: ",w)
        
gaussSeidel(1)
