diff --git a/matlab/sylvester3a.m b/matlab/sylvester3a.m
index f286c8bdfc90dff3e289a63af5374073a8bf289a..cddcbc1ef3e63cbef320b52a044dd3acc1f94e4c 100644
--- a/matlab/sylvester3a.m
+++ b/matlab/sylvester3a.m
@@ -1,7 +1,7 @@
 function [x0, flag]=sylvester3a(x0,a,b,c,dd)
 % solves iteratively ax+bxc=d
 
-% Copyright (C) 2005-2017 Dynare Team
+% Copyright (C) 2005-2017,2020 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -25,7 +25,7 @@ for j=1:size(dd,3)
     d = a_1*dd(:,:,j);
     e = 1;
     iter = 1;
-    while e > 1e-8 && iter < 500
+    while all(e > 1e-8) && iter < 500 %use all() to get a logical in case e is empty
         x = d-b*x0(:,:,j)*c;
         e = max(max(abs(x-x0(:,:,j))));
         x0(:,:,j) = x;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index feaa74da48dd30060553e49db264f184f5875582..d41688256b89eb902457e83d21425b4657b7d78d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -208,6 +208,7 @@ MODFILES = \
 	identification/rbc_ident/rbc_ident_std_as_structural_par.mod \
 	identification/rbc_ident/rbc_ident_varexo_only.mod \
 	identification/correlated_errors/fs2000_corr.mod \
+	identification/forward_looking/forward_looking.mod \
 	simul/example1.mod \
 	simul/Solow_no_varexo.mod \
 	simul/simul_ZLB_purely_forward.mod \
diff --git a/tests/identification/forward_looking/forward_looking.mod b/tests/identification/forward_looking/forward_looking.mod
new file mode 100755
index 0000000000000000000000000000000000000000..bf7c18d3b815524679928d1f833872cc4884400d
--- /dev/null
+++ b/tests/identification/forward_looking/forward_looking.mod
@@ -0,0 +1,70 @@
+% Forward-looking example model from Koop, Pesaran, Smith (2013, JBES)
+% created by Willi Mutschler (@wmutschl, willi@mutschler.eu)
+% =========================================================================
+% Copyright (C) 2020 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
+% =========================================================================
+var r x p;
+varexo e_M e_D e_S;
+varobs r x p;
+
+parameters PSI TAU BETA KAPPA;
+
+PSI=1.1;
+TAU=2;
+BETA=0.9;
+KAPPA=0.6;
+
+model;
+r = PSI*p + e_M;
+x = x(+1) - 1/TAU*(r-p(+1)) + e_D;
+p = BETA*p(+1) + KAPPA*x + e_S;
+end;
+
+shocks;
+var e_M = 1;
+var e_D = 1;
+var e_S = 1;
+end;
+
+steady;
+check;
+
+estimated_params;
+PSI,   1.1;
+TAU,   2;
+BETA,  0.9;
+KAPPA, 0.6;
+end;
+
+identification; %this triggers sylvester3a with empty ghx
+
+% as a side note, we have the true solution:
+% [r;x;p] = TRUE_SOLUTION*[e_M;e_D;e_S] (ghx is empty)
+A = [1 0 -PSI; 1/TAU 1 0; 0 -KAPPA 1];
+TRUE_SOLUTION1 = inv(A);
+TRUE_SOLUTION2 = 1/(KAPPA*PSI/TAU +1)*[1         KAPPA*PSI PSI;
+                                      -1/TAU     1         -PSI/TAU;
+                                      -KAPPA/TAU KAPPA     1];
+% note that BETA drops out from the solution
+
+if max(max(abs(TRUE_SOLUTION1 - oo_.dr.ghu))) > 1e-15
+    error('Something wrong with perturbation');
+end
+if max(max(abs(TRUE_SOLUTION2 - oo_.dr.ghu))) > 1e-15
+    error('Something wrong with perturbation');
+end
\ No newline at end of file