Skip to content

linearize: the input Jacobians are evaluated at the guess of an input that the initialization solves for #5224

Description

@baggepinnen

Goal. I want to linearize a plant at a steady-state operating point that is specified by output targets. The inputs that hold the outputs at those targets are to be solved for by the initialization, as SciML/ModelingToolkit.jl#4830 made possible with u => missing in op.

What I tried. The steady-state condition D(x) => 0, the target y => 4, the input u => missing with a guess, and x => nothing to remove the initial condition of the state:

using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D

@variables x(t) = 1.0 u(t) [input = true] y(t) [output = true]
@named sys = System([D(x) ~ -x + u^2, y ~ x], t)

op = Dict(y => 4.0, D(x) => 0.0, u => missing, x => nothing)
mats, ssys, extras = ModelingToolkit.linearize(sys, [u], [y]; op, guesses = Dict(u => 1.0, x => 1.0))

How it fails. The initialization finds the operating point: extras.x == [4.0], and extras.p holds the solved input u = 2.0. The input matrix, however, is the Jacobian at the guess of the input rather than at the solved value:

julia> mats.A
1×1 Matrix{Float64}:
 -1.0

julia> mats.B
1×1 Matrix{Float64}:
 2.0

At the operating point, ∂(-x + u²)/∂u = 2u = 4; the value 2 is 2u at the guess u = 1. The state Jacobian is correct.

In src/linearization.jl, the call method of LinearizationFunction reads the input values (linfun.inputs_getter(linfun.prob)) before SciMLBase.get_initial_values, and passes these values to pf_jac and hp_jac. The code on master reads them at the same point. I have not run the example on master.

Is there an intended way to obtain the linearization at the inputs the initialization solves for? A single linearize call at such an operating point is what I would like to use.

Versions: ModelingToolkit 11.43.1, ModelingToolkitBase 1.73.0, Julia 1.12.7.

Activity

  1. ChrisRackauckas-Claude commented on Sep 30, 2026

    @ChrisRackauckas-Claude
    Member

    Taking this — Cursor Agent CLI 2026.09.28-64d2043, model auto (local job 5224-cursor on amdci2.julia.csail.mit.edu).

  2. added a commit that references this issue on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions