diff --git a/src/ExprNode.cc b/src/ExprNode.cc
index 4bf7d466f2974e124eae251426d211807bdc684f..4de5a55d2ba0fff5d147a6ecb3a2c4bdd15a75bf 100644
--- a/src/ExprNode.cc
+++ b/src/ExprNode.cc
@@ -7503,7 +7503,18 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo
   int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
   assert(first_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
 
-  if (first_deriv_symb_id == symb_id || alreadyWrittenAsTefTerm(first_deriv_symb_id, tef_terms))
+  /* For a node with derivs provided by the user function, call the method
+     on the non-derived node */
+  if (first_deriv_symb_id == symb_id)
+    {
+      expr_t parent = datatree.AddExternalFunction(symb_id, arguments);
+      parent->compileExternalFunctionOutput(CompileCode, instruction_number, lhs_rhs,
+                                            temporary_terms, temporary_terms_idxs,
+                                            dynamic, steady_dynamic, tef_terms);
+      return;
+    }
+
+  if (alreadyWrittenAsTefTerm(first_deriv_symb_id, tef_terms))
     return;
 
   unsigned int nb_add_input_arguments = compileExternalFunctionArguments(CompileCode, instruction_number, lhs_rhs, temporary_terms,