Skip to content

Remove incorrect logistic (sigmoid) convexity rule - #124

Merged
ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:fix-logistic-convexity-rule
Jul 12, 2026
Merged

Remove incorrect logistic (sigmoid) convexity rule#124
ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:fix-logistic-convexity-rule

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Note

This PR should be ignored until reviewed by @ChrisRackauckas.

Surfaced by the trace-coverage spike in #121. logistic (the sigmoid 1/(1+exp(-x)), from LogExpFunctions) was registered as Convex, but the sigmoid is not globally convex: its second derivative s(1-s)(1-2s) is positive for x<0, zero at x=0, and negative for x>0 (inflection at the origin). Verified numerically:

logistic''(-3) = +0.041   logistic''(-1) = +0.091   logistic''(0) = 0   logistic''(+1) = -0.091   logistic''(+3) = -0.041

The rule looks like a sigmoid-vs-softplus mix-up (the logistic loss / softplus log(1+exp(x)) is convex; the sigmoid is not). The rule is dead todaylogistic(x) expands to a / expression during tracing, so it never fires and analyze already returns UnknownCurvature — but it is a latent trap: hasdcprule(logistic) is true, so anyone later preserving logistic as a symbolic atom would silently activate a false Convex certification.

Removes the rule (src/atoms.jl) and its docs row (docs/src/atoms.md). Behavior-preserving for analyze output (still UnknownCurvature); it removes the trap. Test asserts !hasdcprule(logistic) (fails before, passes after) and the honest UnknownCurvature result. Full suite passes.

Part of #121.

🤖 Generated with Claude Code

logistic (the sigmoid 1/(1+exp(-x)) from LogExpFunctions) was registered
as Convex, but the sigmoid is not globally convex: its second derivative
s(1-s)(1-2s) is positive for x<0, zero at x=0, negative for x>0
(inflection at the origin). The rule appears to confuse the sigmoid with
the logistic loss / softplus log(1+exp(x)), which is convex.

The rule is dead today (logistic(x) expands to a `/` expression, so it
never fires and analyze already returns UnknownCurvature) but is a latent
trap: hasdcprule(logistic) is true, so preserving logistic as a symbolic
atom later would silently activate a false Convex certification. Remove
the rule and its docs row.

Part of SciML#121.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 12, 2026 19:54
@ChrisRackauckas
ChrisRackauckas merged commit 6d40f0d into SciML:main Jul 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants