From aed66bc97c9dda0b31e6a1a6c52957c139614ffd Mon Sep 17 00:00:00 2001
From: "Vladimir V. Kisil" <kisilv@maths.leeds.ac.uk>
Date: Tue, 5 Nov 2013 07:13:47 +0000
Subject: [PATCH 2/4] Derivative of conjugated is conjugated of derivative.

Conjugate of a derivative with respect of a real symbol
If x is real then U.diff(x)-I*V.diff(x) represents both
conjugate(U+I*V).diff(x) and conjugate((U+I*V).diff(x))
This small patch adds the rule

conjugate(f)'=conjugate(f')

for the real symbol.

Signed-off-by: Vladimir V. Kisil <kisilv@maths.leeds.ac.uk>
---
 ginac/inifcns.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp
index 7692b34..82edc61 100644
--- a/ginac/inifcns.cpp
+++ b/ginac/inifcns.cpp
@@ -24,6 +24,7 @@
 #include "ex.h"
 #include "constant.h"
 #include "lst.h"
+#include "fderivative.h"
 #include "matrix.h"
 #include "mul.h"
 #include "power.h"
@@ -66,6 +67,16 @@ static ex conjugate_conjugate(const ex & arg)
 	return arg;
 }
 
+// If x is real then U.diff(x)-I*V.diff(x) represents both conjugate(U+I*V).diff(x) 
+// and conjugate((U+I*V).diff(x))
+static ex conjugate_impl_derivative(const ex & arg, const symbol & s)
+{
+	if (s.info(info_flags::real))
+		return conjugate(arg).diff(s);
+	else
+		return conjugate(arg.diff(s));
+}
+
 static ex conjugate_real_part(const ex & arg)
 {
 	return arg.real_part();
@@ -115,6 +126,7 @@ static bool conjugate_info(const ex & arg, unsigned inf)
 
 REGISTER_FUNCTION(conjugate_function, eval_func(conjugate_eval).
                                       evalf_func(conjugate_evalf).
+                                      impl_derivative_func(conjugate_impl_derivative).
                                       info_func(conjugate_info).
                                       print_func<print_latex>(conjugate_print_latex).
                                       conjugate_func(conjugate_conjugate).
-- 
2.1.1

