%Implicit Euler's
function [ baller, er, matx, maty ] = euler_implicit(func, a, y0, t0, tf, h)

%Init time step
t = t0;

%Init y value
y = y0;

%Calc steps
N = (tf-t0)/h;

%The true value for HW8Q2
true = -1.839396746023524;

%Loop for euler's method
for j = 1:N
    
    %Euler's method function at y (IMPLICIT)
    y = (y + h*(-1000*exp(-(t+h))))/(1 + a*h);
    
    %Calc error at this y
    er = abs((((abs(true)) - (abs(y)))/(abs(true)))*100);

    %Next time step
    t = t + h;
    
    matx(j) = t;
    maty(j) = y;
end

%Outputs value
baller = y;

