From 6bd882b18bc60fafa28a02d4525bf3c9f67083ea Mon Sep 17 00:00:00 2001 From: Aaron Kaw Date: Thu, 5 Sep 2024 01:29:47 +1000 Subject: [PATCH] Added BasicSymbolic as input for function fed to derivative and fixed error report --- src/diff.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diff.jl b/src/diff.jl index 891e2cde2..c08a11201 100644 --- a/src/diff.jl +++ b/src/diff.jl @@ -371,8 +371,8 @@ derivative(::typeof(+), args::NTuple{N,Any}, ::Val) where {N} = 1 derivative(::typeof(*), args::NTuple{N,Any}, ::Val{i}) where {N,i} = *(deleteat!(collect(args), i)...) derivative(::typeof(one), args::Tuple{<:Any}, ::Val) = 0 -derivative(f::Function, x::Num) = derivative(f(x), x) -derivative(::Function, x::Any) = TypeError(:derivative, "2nd argument", Num, typeof(x)) |> throw +derivative(f::Function, x::Union{Num, <:BasicSymbolic}) = derivative(f(x), x) +derivative(::Function, x::Any) = TypeError(:derivative, "2nd argument", Union{Num, <:BasicSymbolic}, x) |> throw function count_order(x) @assert !(x isa Symbol) "The variable $x must have an order of differentiation that is greater or equal to 1!"