function [u] = transforminv2_GL(v2sp,x,vsp,d,p)

u0 = 5000;
opts = optimoptions('fsolve','Display','off','Algorithm','levenberg-marquardt');
u = fsolve(@(u) rootu(v2sp,x,d,p,u),u0,opts);

    function F = rootu(v2sp,x,d,p,u)
        
        c_A = x(1);
        T = x(2);
        
        Q = u; 
        
        T_1 = d(1);
        c_Af = d(2);
        
        T_ref = p(1);                          %reference temp for rate constant [K]
        V = p(2);                                                    %tank volume [m3]
        c_p = p(3);                               %specific heat capacity [kJ/kgK]
        E = p(4);                                     %activation energy [kJ/kmol]
        rho = p(5);                                                %density [kg/m3]
        k_ref = p(6);                               %reference rate constant [min-1]
        R = p(7);                               %universal gas constant [kJ/Kkmol]
        H_rx = p(8);                                   %heat of reaction [kJ/kmol]
        q_1 = p(9);                                     %inlet flow [m3/min]

        k = k_ref*exp((-E/R)*((1/T)-(1/T_ref)));
        
        F = (q_1/V)*(T_1-T)-(H_rx*k*c_A)/(rho*c_p)+(Q/(V*rho*c_p))+0.1874*T - v2sp;
     
        
    end


end 