Skip to content
Learn Netverks

Lesson

Step 13/36 36% through track

minimize-scalar

Minimize scalar functions

Last reviewed Jun 1, 2026 Content v20260601
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Minimize scalar functions: SciPy scientific routines on NumPy arrays—statistics, optimization, linear algebra, and numerical methods.

Fitting parameters appears everywhere—from calibration to ML loss minimization.

You will apply Minimize scalar functions in contexts like: Research code, engineering simulations, and specialized analytics.

Read the narrative, run NumPy + SciPy snippets in the playground (install scipy and numpy with pip if needed), inspect outputs and convergence, and complete MCQs. Also verify the reported optimum by evaluating the objective nearby.

When you can explain the previous lesson's ideas in your own words.

optimize.minimize_scalar optimizes f(x) for a single real variable—ideal when you can bracket a minimum or search within bounds.

Methods

  • method='brent' — bracketed univariate (default)
  • method='bounded' — requires bounds=(a, b)
  • method='golden' — golden-section search

Bracket intuition

Provide bracket=(a, b) where f(a) > f(c) < f(b) for some interior c—or use bounds. Wrong brackets miss the minimum.

Example

import numpy as np
from scipy import optimize

def f(x):
    return (x - 1.5) ** 2 + 0.1 * np.sin(10 * x)

res = optimize.minimize_scalar(f, bracket=(0, 3))
print('x:', res.x, 'f(x):', res.fun)

Important interview questions and answers

  1. Q: When scalar vs vector minimize?
    A: One decision variable (step size, learning rate grid) → scalar; multiple parameters → minimize.
  2. Q: bounded method?
    A: Use when x must stay in an interval—e.g. probability in [0, 1].

Self-check

  1. What does bracket mean for Brent's method?
  2. Write a scalar function with a known minimum at x=2.

Pitfall: Wrong bracket → wrong minimum—plot the scalar function first.

Interview prep

When scalar?

Single decision variable—bracket or bounded search.

bounded method?

Parameters constrained to interval—probabilities, physical limits.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Brent method?
  • Bracket interval?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump