--- ./boost/math/octonion.hpp~	2011-08-02 21:24:08.000000000 +0900
+++ ./boost/math/octonion.hpp	2011-08-10 19:25:46.000000000 +0900
@@ -4759,7 +4759,7 @@
             T    z = abs(unreal(q));
 
             // log(q) = log(|q|) + Vq/|Vq| atan(|Vq|/Sq)
-            return(log(abs(q)) + ((z != static_cast<T>(0)) ? unreal(q)/z*(atan2(z, real(q))) : octonion  <T>(0, (real(q)<0)?M_PI:0, 0, 0, 0, 0, 0, 0)));
+            return(log(abs(q)) + ((z != static_cast<T>(0)) ? unreal(q)/z*(atan2(z, real(q))) : octonion  <T>(0, 1, 0, 0, 0, 0, 0, 0)*static_cast<T>((real(q) < 0) ? M_PI : 0)));
         }
         
         
@@ -4827,18 +4827,21 @@
             //  = -UVq/2 log( (1-q UVq)^{-1} (1+q UVq) )
             //return(-u/static_cast<T>(2)*log(static_cast<T>(1)/(static_cast<T>(1)-q*(u))*(static_cast<T>(1)+q*(u))));
             octonion  <T> d = static_cast<T>(1)-q*(u), c = static_cast<T>(1)/d*(static_cast<T>(1)+q*(u)), r = -u/static_cast<T>(2)*log(c);
+            // the signs of realpart are different with complex ones when Sq == 0 && Vq < -1
+	    r = r.real()*static_cast<T>((real(q) != static_cast<T>(0) || real(octonion  <T>(0, 1, 0, 0, 0, 0, 0, 0)*q) < 1) ? 1 : -1) + r.unreal();
             //return((abs(d) != static_cast<T>(0) && abs(c) != static_cast<T>(0)) ? r : octonion  <T>(0));
             return((abs(d) != static_cast<T>(0) && abs(c) != static_cast<T>(0)) ? ((abs(unreal(q)) != static_cast<T>(0)) ? r : octonion  <T>(real(r))) : octonion  <T>(0));
-            // the signs of realpart are different with complex ones when Sq == 0 && Vq < -1
 #else
             // atan(q) = -UVq atanh(q UVq)
             //return(static_cast<T>(1)/u*atanh(q*u)); // the signs of realpart are different with complex ones when Sq == 0 && Vq < -1
 	    octonion  <T> p = q*u;
 	    octonion  <T> v = (abs(unreal(p)) != static_cast<T>(0)) ? unreal(p)/abs(unreal(p)) : octonion  <T>(0, 1, 0, 0, 0, 0, 0, 0);
             octonion  <T> d = (static_cast<T>(1)-p), c = static_cast<T>(1)/d*(static_cast<T>(1)+p), r = static_cast<T>(1)/static_cast<T>(2)*log(c);
+	    r = r.real() + r.unreal()*static_cast<T>((real(q) != static_cast<T>(0) || real(octonion  <T>(0, 1, 0, 0, 0, 0, 0, 0)*q) < 1) ? 1 : -1);
+	    // the signs of realpart are different with complex ones when Sq == 0 && Vq < -1
             r = (abs(d) != static_cast<T>(0) && abs(c) != static_cast<T>(0)) ? ((real(p) != static_cast<T>(0)) ? r : r.unreal()) : octonion  <T>(0);
 	    r = -u*r;
-	    return(r); // the signs of realpart are different with complex ones when Sq == 0 && Vq < -1
+	    return(r);
 #endif
         }
         
@@ -4871,14 +4874,17 @@
         {
 #if 1
             // asinh(q) = log(q + sqrt(q^2 + 1))
-            return(log(q + sqrt(pow(q, 2) + static_cast<T>(1)))); // the signs of realpart are different with complex ones when Sq == 0 && Vq > 1
+            //return(log(q + sqrt(pow(q, 2) + static_cast<T>(1)))); // the signs of realpart are different with complex ones when Sq == 0 && Vq > 1
+	    octonion  <T> r = log(q + sqrt(pow(q, 2) + static_cast<T>(1)));
+	    return(r.real()*static_cast<T>((real(q) != static_cast<T>(0) || real(octonion  <T>(0, 1, 0, 0, 0, 0, 0, 0)*q) > 1) ? 1 : -1) + r.unreal());
 #else
             octonion  <T> u = (abs(unreal(q)) != static_cast<T>(0)) ? unreal(q)/abs(unreal(q)) : octonion  <T>(0, 1, 0, 0, 0, 0, 0, 0);
 	    // asinh(q) = UVq asin(-q UVq)
 	    //return(u*asin(-q*u)); // the signs of realpart are different with complex ones when Sq == 0 && Vq < 1
 	    octonion  <T> p = -q*u;
 	    octonion  <T> v = (abs(unreal(p)) != static_cast<T>(0)) ? unreal(p)/abs(unreal(p)) : octonion  <T>(0, 1, 0, 0, 0, 0, 0, 0);
-	    return(u*(-v*log(p*v + sqrt(static_cast<T>(1) - pow(p, 2))))); // the signs of realpart are different with complex ones when Sq == 0 && Vq > 1
+	    quaternion<T> r = u*(-v*log(p*v + sqrt(static_cast<T>(1) - pow(p, 2)))); // the signs of realpart are different with complex ones when Sq == 0 && Vq > 1
+	    return(r.real()*static_cast<T>((real(q) != static_cast<T>(0) || real(octonion  <T>(0, 1, 0, 0, 0, 0, 0, 0)*q) > 1) ? 1 : -1) + r.unreal());
 #endif
         }
         
--- ./boost/math/quaternion.hpp~	2011-08-02 20:25:05.000000000 +0900
+++ ./boost/math/quaternion.hpp	2011-08-10 19:11:24.000000000 +0900
@@ -1953,7 +1953,7 @@
             T    z = abs(unreal(q));
 
             // log(q) = log(|q|) + Vq/|Vq| atan(|Vq|/Sq)
-            return(log(abs(q)) + ((z != static_cast<T>(0)) ? unreal(q)/z*(atan2(z, real(q))) : quaternion<T>(0, (real(q)<0)?M_PI:0, 0, 0)));
+            return(log(abs(q)) + ((z != static_cast<T>(0)) ? unreal(q)/z*(atan2(z, real(q))) : quaternion<T>(0, 1, 0, 0)*static_cast<T>((real(q) < 0) ? M_PI : 0)));
         }
         
         
@@ -2017,18 +2017,21 @@
             //  = -UVq/2 log( (1-q UVq)^{-1} (1+q UVq) )
             //return(-u/static_cast<T>(2)*log(static_cast<T>(1)/(static_cast<T>(1)-q*(u))*(static_cast<T>(1)+q*(u))));
             quaternion<T> d = static_cast<T>(1)-q*(u), c = static_cast<T>(1)/d*(static_cast<T>(1)+q*(u)), r = -u/static_cast<T>(2)*log(c);
+            // the signs of realpart are different with complex ones when Sq == 0 && Vq < -1
+	    r = r.real()*static_cast<T>((real(q) != static_cast<T>(0) || real(quaternion<T>(0, 1, 0, 0)*q) < 1) ? 1 : -1) + r.unreal();
             //return((abs(d) != static_cast<T>(0) && abs(c) != static_cast<T>(0)) ? r : quaternion<T>(0));
             return((abs(d) != static_cast<T>(0) && abs(c) != static_cast<T>(0)) ? ((abs(unreal(q)) != static_cast<T>(0)) ? r : quaternion<T>(real(r))) : quaternion<T>(0));
-            // the signs of realpart are different with complex ones when Sq == 0 && Vq < -1
 #else
             // atan(q) = -UVq atanh(q UVq)
             //return(static_cast<T>(1)/u*atanh(q*u)); // the signs of realpart are different with complex ones when Sq == 0 && Vq < -1
 	    quaternion<T> p = q*u;
 	    quaternion<T> v = (abs(unreal(p)) != static_cast<T>(0)) ? unreal(p)/abs(unreal(p)) : quaternion<T>(0, 1, 0, 0);
             quaternion<T> d = (static_cast<T>(1)-p), c = static_cast<T>(1)/d*(static_cast<T>(1)+p), r = static_cast<T>(1)/static_cast<T>(2)*log(c);
+	    r = r.real() + r.unreal()*static_cast<T>((real(q) != static_cast<T>(0) || real(quaternion<T>(0, 1, 0, 0)*q) < 1) ? 1 : -1);
+	    // the signs of realpart are different with complex ones when Sq == 0 && Vq < -1
             r = (abs(d) != static_cast<T>(0) && abs(c) != static_cast<T>(0)) ? ((real(p) != static_cast<T>(0)) ? r : r.unreal()) : quaternion<T>(0);
 	    r = -u*r;
-	    return(r); // the signs of realpart are different with complex ones when Sq == 0 && Vq < -1
+	    return(r);
 #endif
         }
         
@@ -2061,14 +2064,17 @@
         {
 #if 1
             // asinh(q) = log(q + sqrt(q^2 + 1))
-            return(log(q + sqrt(pow(q, 2) + static_cast<T>(1)))); // the signs of realpart are different with complex ones when Sq == 0 && Vq > 1
+            //return(log(q + sqrt(pow(q, 2) + static_cast<T>(1)))); // the signs of realpart are different with complex ones when Sq == 0 && Vq > 1
+	    quaternion<T> r = log(q + sqrt(pow(q, 2) + static_cast<T>(1)));
+	    return(r.real()*static_cast<T>((real(q) != static_cast<T>(0) || real(quaternion<T>(0, 1, 0, 0)*q) > 1) ? 1 : -1) + r.unreal());
 #else
             quaternion<T> u = (abs(unreal(q)) != static_cast<T>(0)) ? unreal(q)/abs(unreal(q)) : quaternion<T>(0, 1, 0, 0);
 	    // asinh(q) = UVq asin(-q UVq)
 	    //return(u*asin(-q*u)); // the signs of realpart are different with complex ones when Sq == 0 && Vq < 1
 	    quaternion<T> p = -q*u;
 	    quaternion<T> v = (abs(unreal(p)) != static_cast<T>(0)) ? unreal(p)/abs(unreal(p)) : quaternion<T>(0, 1, 0, 0);
-	    return(u*(-v*log(p*v + sqrt(static_cast<T>(1) - pow(p, 2))))); // the signs of realpart are different with complex ones when Sq == 0 && Vq > 1
+	    quaternion<T> r = u*(-v*log(p*v + sqrt(static_cast<T>(1) - pow(p, 2)))); // the signs of realpart are different with complex ones when Sq == 0 && Vq > 1
+	    return(r.real()*static_cast<T>((real(q) != static_cast<T>(0) || real(quaternion<T>(0, 1, 0, 0)*q) > 1) ? 1 : -1) + r.unreal());
 #endif
         }
         
