Fix documentation examples for Symbolics.jl v7 compatibility#491
Merged
ChrisRackauckas merged 1 commit intoDec 30, 2025
Merged
Conversation
In Symbolics.jl v7+, `substitute` no longer fully evaluates symbolic
expressions containing registered function calls to numeric values.
Instead, it only performs symbolic substitution.
The fix updates the documentation examples in `symbolics.md` to use
`build_function` instead of `substitute` for numeric evaluation:
- Build an evaluable function from the symbolic expression using
`build_function(ex, τ, expression = Val{false})`
- Call the generated function with the numeric value
- Use approximate equality (≈) for floating-point comparisons
This approach is consistent with the intended use of Symbolics.jl
where `build_function` is the recommended way to convert symbolic
expressions to callable functions.
Fixes SciML#490
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the failing documentation build caused by breaking changes in Symbolics.jl v7+ (see #490).
Root Cause: In Symbolics.jl v7+,
substituteno longer fully evaluates symbolic expressions containing registered function calls to numeric values. Instead, it only performs symbolic substitution, returning aNumtype with the variable replaced but functions kept unevaluated.Solution: Use
build_functioninstead ofsubstitutefor numeric evaluation:build_function(ex, τ, expression = Val{false})≈) for floating-point comparisonsThis approach is consistent with the intended use of Symbolics.jl where
build_functionis the recommended way to convert symbolic expressions to callable functions.Changes
docs/src/symbolics.md: Updated both @example blocks to usebuild_functioninstead ofsubstitutefor numeric evaluationTest plan
Pkg.test()) - all tests passFixes #490
cc @ChrisRackauckas
🤖 Generated with Claude Code