Skip to content
cccskills
FreePublished on GitHub

gradient-methods

Work through optimization problems using gradients, which indicate how a function changes. The skill guides method selection, step size choices, and convergence checks, with SciPy examples for conjugate gradient and BFGS methods.

OriginalShow the original description

Problem-solving strategies for gradient methods in optimization

See how to install

Good for

  • Choosing a method for an optimization problem
  • Adjusting gradient descent step sizes
  • Investigating oscillation or slow convergence
  • Trying conjugate gradient or BFGS with SciPy

Files included (1)

  • SKILL.md4.0 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Gradient Methods

When to Use

Use this skill when working on gradient-methods problems in optimization.

Decision Tree

  1. Basic Gradient Descent

    • Update: x_{k+1} = x_k - alpha * grad f(x_k)
    • Step size alpha: fixed, diminishing, or line search
    • Convergence: O(1/k) for convex, linear for strongly convex
  2. Step Size Selection

    MethodApproach
    Fixedalpha constant (requires tuning)
    BacktrackingArmijo condition: f(x - alphagrad) <= f(x) - calpha*
    Exact line searchminimize f(x - alpha*grad) over alpha
    AdaptiveAdam, RMSprop (ML applications)
  3. Accelerated Methods

    • Momentum: add velocity term
    • Nesterov: look-ahead gradient
    • Conjugate gradient: for quadratic functions
    • scipy.optimize.minimize(f, x0, method='CG') - conjugate gradient
  4. Newton's Method

    • Update: x_{k+1} = x_k - H^{-1} * grad f
    • Requires Hessian (expensive but quadratic convergence)
    • Quasi-Newton (BFGS): approximate Hessian
    • scipy.optimize.minimize(f, x0, method='BFGS')
  5. Convergence Diagnostics

    • Monitor ||grad f|| < tolerance
    • Check function value decrease
    • Watch for oscillation (step size too large)
    • sympy_compute.py diff "f" --var x for gradient

Tool Commands

Scipy_Bfgs

uv run python -c "from scipy.optimize import minimize; res = minimize(lambda x: (x[0]-1)**2 + 100*(x[1]-x[0]**2)**2, [0, 0], method='BFGS'); print('Rosenbrock min at', res.x)"

Scipy_Cg

uv run python -c "from scipy.optimize import minimize; res = minimize(lambda x: x[0]**2 + x[1]**2, [1, 1], method='CG'); print('Min at', res.x)"

Sympy_Gradient

uv run python -m runtime.harness scripts/sympy_compute.py diff "x**2 + y**2" --var "[x, y]"

Key Techniques

From indexed textbooks:

  • [nonlinear programming_tif] Gradient Methods** - These methods use gradient information to iteratively approach the optimum. Convergence** - Addressing convergence properties. Descent Directions and Stepsize Rules:** Focuses on how to choose descent directions and appropriate step sizes.
  • [nonlinear programming_tif] The application of gradient methods to unconstrained optimal control prob- lems is straightforward in principle. For example the steepest descent method takes the form W = b oMV H, (kb ph,y), i=0,. Pl = Thus, given u¥, one computes zF by forward propagation of the system equation, and then p*¥ by backward propagation of the adjoint equation.
  • [nonlinear programming_tif] Footer or Trailing Row**: - There is an empty concluding element indicated by a single ". Overall, this table serves as an index for chapters or sections within a document, with particular emphasis on optimization methods and related mathematical strategies, as evidenced by the listed methods like Gradient, Newton, and other derivative techniques. The scattered letters and empty slots may denote a form of stylistic or formatting choice rather than meaningful content in this context.
  • [nonlinear programming_tif] Zoutendijk’s method uses tw ) oscalatse)Oand'ye 0,1), a i ! P, where ¢ — Y™k € and my is the firs onnegative k ok 28 %, ) it T #(z*,7"e) < -y (a) Show that (b) Prove that {d*} is gradient relat ishi i i Tt pones A related, thus establishing stationarity of the 2. Min-H Method for Optimal Control) Consider the problem of findin g sequences u = (z1,22,.
  • [nonlinear programming_tif] Mustration of the function f of Exercise 1. Stability) (www) We are often interested in whether optimal solutions change radically when the problem data are slightly perturbed. This issue is addressed by stability analysis, to be contrasted with sensitivity analysis, which deals with how much optimal solutions change when problem data change.

Cognitive Tools Reference

See .claude/skills/math-mode/SKILL.md for full tool documentation.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

adaptyv

FreeSummary

Support experimental validation of designed proteins through a cloud laboratory. Prepare and optimize sequences, submit tests for binding, expression, thermal stability, or enzyme activity, track experiment progress, and retrieve results through the API.

  • Submit designed proteins for binding tests
  • Request expression, thermal stability, or enzyme activity tests
  • Optimize sequences for solubility before experiments
foryourhealth111-pixel/Vibe-Skills3.8KUpdated Oct 20, 2026

aeon

FreeSummary

Analyze time series, observations ordered over time, using aeon in Python. Build classification, prediction, and clustering workflows, detect unusual patterns or changes, and compare methods through an interface compatible with scikit-learn.

  • Classifying time series by their patterns
  • Forecasting future values from past observations
  • Detecting anomalies and change points
foryourhealth111-pixel/Vibe-Skills3.8KUpdated Oct 20, 2026

algorithmic-art

FreeSummary

Create original generative art with p5.js, using code to produce patterns and motion. Receive a written artistic concept and an interactive HTML viewer with adjustable parameters, reproducible random variations, seed navigation, and PNG downloads.

  • Create art from particle motion and flow fields
  • Explore patterns by adjusting sliders
  • Reproduce a favorite variation with the same seed
foryourhealth111-pixel/Vibe-Skills3.8KUpdated Oct 20, 2026

alpha-vantage

FreeSummary

Retrieve stock prices, exchange rates, cryptocurrency prices, company financial statements, and economic indicators through the Alpha Vantage API. It also covers historical data, news sentiment, and technical indicators, which summarize price and trading patterns.

  • Retrieve historical stock prices and trading volumes
  • Collect company financial statements and earnings data
  • Check foreign exchange and cryptocurrency prices
foryourhealth111-pixel/Vibe-Skills3.8KUpdated Oct 20, 2026

Design backend systems with clear boundaries between business rules, databases, and external services. Use Clean Architecture, Hexagonal Architecture, and Domain-Driven Design to organize new applications, refactor existing code, and make core logic easier to test.

  • Planning the structure of a new backend
  • Refactoring tightly coupled applications
  • Testing business rules independently of external services
foryourhealth111-pixel/Vibe-Skills3.8KUpdated Oct 20, 2026

astropy

FreeSummary

Helps process astronomical data in Python by converting coordinates, units, and time scales, working with FITS observation files, matching object catalogs, and calculating distances using cosmological models.

  • Converting celestial coordinates
  • Reading and editing FITS observation files
  • Matching objects across astronomical catalogs
foryourhealth111-pixel/Vibe-Skills3.8KUpdated Oct 20, 2026

See all skills by foryourhealth111-pixel

Report a problem with this skill