@@ -18,7 +18,10 @@ A = LinearInterpolation(u, t)
1818
1919# Simple Expression
2020ex = 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
3235ex2 = 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
3742ex3 = 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