Skip to content

Commit 6b09a9f

Browse files
Merge pull request #491 from ChrisRackauckas-Claude/claude-fix-issue-490
Fix documentation examples for Symbolics.jl v7 compatibility
2 parents e91b17a + 40ba0bc commit 6b09a9f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

docs/src/symbolics.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ A = LinearInterpolation(u, t)
1818
1919
# Simple Expression
2020
ex = cos(τ) * A(τ)
21-
@test substitute(ex, Dict(τ => 0.5)) == cos(0.5) * A(0.5) # true
21+
22+
# Build a function from the symbolic expression and evaluate it
23+
f_ex = build_function(ex, τ, expression = Val{false})
24+
@test f_ex(0.5) ≈ cos(0.5) * A(0.5) # true
2225
```
2326

2427
### Symbolic Derivatives
@@ -31,12 +34,15 @@ ex1 = A(τ)
3134
# Derivative of interpolation
3235
ex2 = expand_derivatives(D(ex1))
3336
34-
@test substitute(ex2, Dict(τ => 0.5)) == DataInterpolations.derivative(A, 0.5) # true
37+
# Build a function from the derivative expression and evaluate it
38+
f_deriv = build_function(ex2, τ, expression = Val{false})
39+
@test f_deriv(0.5) ≈ DataInterpolations.derivative(A, 0.5) # true
3540
3641
# Higher Order Derivatives
3742
ex3 = expand_derivatives(D(D(A(τ))))
3843
39-
@test substitute(ex3, Dict(τ => 0.5)) == DataInterpolations.derivative(A, 0.5, 2) # true
44+
f_deriv2 = build_function(ex3, τ, expression = Val{false})
45+
@test f_deriv2(0.5) ≈ DataInterpolations.derivative(A, 0.5, 2) # true
4046
```
4147

4248
## Using with ModelingToolkit.jl

0 commit comments

Comments
 (0)