From d908d4b7adc9ece703fead23f3411e3437aefda9 Mon Sep 17 00:00:00 2001
From: Michel Juillard <michel.juillard@mjui.fr>
Date: Fri, 7 Dec 2012 21:45:16 +0100
Subject: [PATCH] fixed bug in computation of derivative of erf() function
 (cherry picked from commit 32b68b713b0de20525f12d002fdca76489483a33)

---
 preprocessor/ExprNode.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/preprocessor/ExprNode.cc b/preprocessor/ExprNode.cc
index 66bef7503..b01d1ebc4 100644
--- a/preprocessor/ExprNode.cc
+++ b/preprocessor/ExprNode.cc
@@ -1322,7 +1322,7 @@ UnaryOpNode::prepareForDerivation()
 expr_t
 UnaryOpNode::composeDerivatives(expr_t darg, int deriv_id)
 {
-  expr_t t11, t12, t13;
+  expr_t t11, t12, t13, t14;
 
   switch (op_code)
     {
@@ -1442,7 +1442,9 @@ UnaryOpNode::composeDerivatives(expr_t darg, int deriv_id)
       // sqrt(pi)*exp(x^2)
       t13 = datatree.AddTimes(t11, t12);
       // 2/(sqrt(pi)*exp(x^2));
-      return datatree.AddDivide(datatree.Two, t13);
+      t14 = datatree.AddDivide(datatree.Two, t13);
+      // (2/(sqrt(pi)*exp(x^2)))*dx;
+      return datatree.AddTimes(t14, darg);
     }
   // Suppress GCC warning
   exit(EXIT_FAILURE);
-- 
GitLab