public static DualNumberGrad Sinh(DualNumberGrad a) { var sin = Math.Sinh(a.Value); var cos = Math.Cosh(a.Value); return(new DualNumberGrad(sin, cos * a.Grad)); }
public static DualNumberGrad Cos(DualNumberGrad a) { var sin = Math.Sin(a.Value); var cos = Math.Cos(a.Value); return(new DualNumberGrad(cos, -sin * a.Grad)); }
public static DualNumberGrad Pow(DualNumberGrad a, double b) { var pow = Math.Pow(a.Value, b); return(new DualNumberGrad(pow, b * pow / a.Value * a.Grad)); }
public static DualNumberGrad Pow(DualNumberGrad a, DualNumberGrad b) => Exp(b * Log(a));
public static DualNumberGrad Log(DualNumberGrad a) { return(new DualNumberGrad(Math.Log(a.Value), a.Grad / a.Value)); }
public static DualNumberGrad Exp(DualNumberGrad a) { var exp = Math.Exp(a.Value); return(new DualNumberGrad(exp, exp * a.Grad)); }
public static DualNumberGrad Sqrt(DualNumberGrad a) { var r = Math.Sqrt(a.Value); return(new DualNumberGrad(r, 0.5 * a.Grad / r)); }
public static DualNumberGrad Inverse(DualNumberGrad a) { return(new DualNumberGrad(1 / a.Value, -a.Grad / (a.Value * a.Value))); }
public static DualVectorGrad Vec(DualNumberGrad x, DualNumberGrad y, DualNumberGrad z) => new DualVectorGrad(x, y, z);
public DualVectorGrad(Vector v) { X = v.X; Y = v.Y; Z = v.Z; }
public DualVectorGrad(DualNumberGrad x, DualNumberGrad y, DualNumberGrad z) { X = x; Y = y; Z = z; }
public static DualNumberGrad Abs(DualNumberGrad a) => a.Value >= 0 ? a : -a;
public static DualNumberGrad Tanh(DualNumberGrad a) { var tan = Math.Tanh(a.Value); return(new DualNumberGrad(tan, (1 - tan * tan) * a.Grad)); }
public static DualNumberGrad Atan(DualNumberGrad a) { return(new DualNumberGrad(Math.Atan(a.Value), a.Grad / (1 + a.Value * a.Value))); }
public static DualNumberGrad Acos(DualNumberGrad a) { return(new DualNumberGrad(Math.Acos(a.Value), -a.Grad / Math.Sqrt(1 - a.Value * a.Value))); }