Skip to content

Fix documentation examples for Symbolics.jl v7 compatibility#491

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:claude-fix-issue-490
Dec 30, 2025
Merged

Fix documentation examples for Symbolics.jl v7 compatibility#491
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:claude-fix-issue-490

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Summary

This PR fixes the failing documentation build caused by breaking changes in Symbolics.jl v7+ (see #490).

Root Cause: In Symbolics.jl v7+, substitute no longer fully evaluates symbolic expressions containing registered function calls to numeric values. Instead, it only performs symbolic substitution, returning a Num type with the variable replaced but functions kept unevaluated.

Solution: Use build_function instead of substitute for numeric evaluation:

  • Build an evaluable Julia 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.

Changes

  • docs/src/symbolics.md: Updated both @example blocks to use build_function instead of substitute for numeric evaluation

Test plan

  • Created and ran MWE to confirm the issue
  • Verified the fix works with Symbolics v7.4.1
  • Ran the full test suite (Pkg.test()) - all tests pass
  • CI will verify the documentation build

Fixes #490

cc @ChrisRackauckas

🤖 Generated with Claude Code

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>
@ChrisRackauckas ChrisRackauckas merged commit 6b09a9f into SciML:master Dec 30, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation build failing with ModelingToolkit v11

2 participants