1.2.8 · HinglishCalculus & Optimization Basics

Convex vs non-convex functions

1,770 words8 min readRead in English

1.2.8 · AI-ML › Calculus & Optimization Basics


HUM CARE KYUN KARTE HAIN? (80/20 core)

Machine learning mostly ek loss function ko minimize karna hai. Poora game yeh hai: aisi parameters dhundho jo loss ko chhota kare.

  • Agar convex hai: essentially ek hi basin hai. Slope ke saath neeche jaao → guaranteed best answer milega. (Linear/logistic regression, SVM.)
  • Agar non-convex hai: multiple valleys, ridges, saddle points. Neeche jaana tumhe ek bekar valley (ek bura local minimum) mein fansa sakta hai. (Neural networks.)

Toh "convex vs non-convex" batata hai tumhari optimization kitni mushkil hai aur jo answer tumhara converge hua usp trust kar sakte ho ya nahi.


CONVEXITY EXACTLY KYA HOTI HAI?


HUM CONVEXITY CHECK KAISE KARTE HAIN? (teen lenses)

Lens 1 — Chord test (definition khud)

Midpoint lo: convex ka matlab hai Outputs ka average kam se kam average ka output hota hai.

Lens 2 — First-order (tangent line) condition

Ek differentiable ke liye, convex graph har tangent line ke upar rehta hai:

Lens 3 — Second-order (curvature) condition — practical wala

Twice-differentiable ke liye:

  • 1D: convex har jagah (upar ki taraf curve karta hai / kabhi neeche nahi modta).
  • Multivariate: convex Hessian har jagah positive semidefinite (PSD) hai, matlab sabhi ke liye.

1D SECOND-ORDER TEST SCRATCH SE DERIVE KARNA

Hum dikhate hain: agar har jagah, toh tangent-line condition (Lens 2) hold karti hai.

Step 1 — Taylor with exact remainder. aur ke beech kisi ke liye: Yeh step kyun? Taylor's theorem ek exact expression deta hai, curvature term ko isolate karta hai.

Step 2 — Remainder ko bound karo. Kyunki aur : Yeh step kyun? Yahi unknown term hai; nonnegative curvature ise nonnegative banati hai.

Step 3 — Conclude karo. Yeh step kyun? Yahi exactly Lens 2 hai — graph tangent ke upar — isliye convex.


Figure — Convex vs non-convex functions

Worked examples


Common mistakes (Steel-manned)


Flashcards

Convex function definition (inequality form)
sabhi ke liye — curve chord ke neeche.
Convexity ka geometric meaning
Graph par koi bhi do points ko join karne wala line segment graph par ya uske upar rehta hai (bowl shape).
1D mein second-order convexity test
domain mein SABHI ke liye.
Multivariate convexity test
Hessian har jagah positive semidefinite hai ().
Convexity ka key optimization payoff
Har local minimum ek global minimum hai (stationary point ⇒ global min).
Kya convex hai?
Nahi — sign change karta hai; ek inflection point hai.
Kya convex hai?
Haan — Hessian , har jagah positive definite.
non-convex kyun hai?
Hessian eigenvalues (indefinite); origin ek saddle point hai.
Kaunse functions convex AUR concave dono hote hain?
Sirf affine (linear + constant) functions.
Neural nets mein non-convex loss kyun hoti hai?
Nonlinear activations ki composition multiple minima/saddles banati hai ⇒ Hessian har jagah PSD nahi.
First-order convexity condition
— graph har tangent line ke upar rehta hai.

Recall Feynman: ek 12-saal ke bachche ko samjhao

Socho ek skateboard ramp. Ek convex ramp ek smooth U-shaped bowl hai: chahe marble kahan bhi girao, woh hamesha ek hi sabse neeche wale point par roll karke aata hai. Easy — tum fasa nahi sakte. Ek non-convex ramp ek bumpy skate park hai jisme bahut saare dips hain. Tumhara marble ek chhote dip mein ruk sakta hai jo sabse gahra nahi hai, yeh sochke "main ho gaya!" jabki ek aur gehri valley seedha pahaad ke paar baithti hai. Convex = ek honest bowl; non-convex = fake bottoms wali tricky landscape.


Connections

Concept Map

needs

defined by

requires

type

type

guarantees

enables

risks

examples

examples

checked by

checked by

checked by

implies

ML minimizes loss L theta

Convexity property

Chord definition f of avg <= avg of f

Convex domain set

Convex single valley bowl

Non-convex many valleys

Local min is global min

Gradient descent finds best

Trapped in bad local min

Linear/logistic regression SVM

Neural networks

Chord test

Tangent line f above tangent

Hessian PSD f'' >= 0