analyze(ex) reports the curvature ("Convex", "Concave", "Affine"
or "UnknownCurvature") and the sign ("Positive", "Negative" or
"AnySign") of a symbolic expression by the composition rules of
disciplined convex programming, as SymbolicAnalysis.jl: sums keep a
common curvature, a product may have one non constant factor (more emit
a warning and give "UnknownCurvature"), and an atom (exp, log,
abs, Max, Min, powers, norm) composes with arguments of matching
curvature and monotonicity.
Details
analyze(ex, M) adds the geodesic curvature on the manifold M
(SymmetricPositiveDefinite() or Lorentz()): "GConvex",
"GConcave", "GLinear" or "GUnknownCurvature", from the rules of
the atoms in gdcp_atoms and add_gdcprule(). A Euclidean rule only
composes over an argument that already has a geodesic curvature. The
signs of the geodesic rules hold on M, so they also enter the sign
and the Euclidean curvature. The variable is a symcompR MatrixSymbol;
Transpose(a) * Y * a becomes quad_form(a, Y) first, as upstream.
Examples
x <- Symbol("x"); y <- Symbol("y")
analyze(exp(x) - log(y))$curvature
#> [1] "Convex"
analyze((x - 1)^2 + 2 * abs(y))$curvature
#> [1] "Convex"
analyze(-x^2)$sign
#> [1] "Negative"
X <- MatrixSymbol("X", 3, 3)
analyze(tr(Inverse(X)) + logdet(X), SymmetricPositiveDefinite(3))
#> AnalysisResult: curvature = UnknownCurvature, sign = AnySign, gcurvature = GConvex