How to Compute Analytical Derivative and Integral of trigonometric functions using Symbolic.jl and DiffRules.jl

Hi all,

I have this equation

y = \frac{1}{e^{\frac{t}{2}}} \left[ \int_{t_{0}}^{t} e^{\frac{s}{2}} (10 + 5 \ sin(2s)) \ ds + c \right] \\

I want to ask how to solve this with Symbolics.jl and DiffRules.jl (even if the packages are derivatives, I know they can be used to check whether the integration is correct)
or are there any package that can help for the integration analytically? or both if possible…

From an old 2021 thread on this discourse I try this code (Derivative of a Symbolic Expression as a Symbol Valued Function):

using Symbolics

@variables a3, a2, a1, a0, t

f0(t) = a3*t^3 + a2*t^2 + a1*t + a0

and it does not work:
┌ Info: Precompiling Symbolics [0c5d862f-8b57-4792-8d23-62f2024744c7]
└ @ Base loading.jl:1423
ERROR: LoadError: UndefVarError: similar_type not defined
Stacktrace:
** [1] include**
** @ ./Base.jl:418 [inlined]**
** [2] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)**
** @ Base ./loading.jl:1318**
** [3] top-level scope**
** @ none:1**
** [4] eval**
** @ ./boot.jl:373 [inlined]**
** [5] eval(x::Expr)**
** @ Base.MainInclude ./client.jl:453**
** [6] top-level scope**
** @ none:1**
in expression starting at /home/browni/.julia/packages/DiffResults/YLo25/src/DiffResults.jl:1
ERROR: LoadError: Failed to precompile DiffResults [163ba53b-c6d8-5494-b064-1a9d43ac40c5] to /home/browni/.julia/compiled/v1.7/DiffResults/jl_sNyCGj.

I also try this:

using Symbolics

@variables x, y, z

f(x,y,z) = x^2 + sin(x+y) - z

Symbolics.derivative(::typeof(my_function), args::NTuple{N,Any}, ::Val{i})

from Derivatives and Differentials · Symbolics.jl

still not working:
Info: Precompiling Symbolics [0c5d862f-8b57-4792-8d23-62f2024744c7]
└ @ Base loading.jl:1423
ERROR: LoadError: UndefVarError: similar_type not defined
Stacktrace:
** [1] include**
** @ ./Base.jl:418 [inlined]**
** [2] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)**
** @ Base ./loading.jl:1318**
** [3] top-level scope**
** @ none:1**
** [4] eval**
** @ ./boot.jl:373 [inlined]**
** [5] eval(x::Expr)**
** @ Base.MainInclude ./client.jl:453**
** [6] top-level scope**
** @ none:1**
in expression starting at /home/browni/.julia/packages/DiffResults/YLo25/src/DiffResults.jl:1
ERROR: LoadError: Failed to precompile DiffResults [163ba53b-c6d8-5494-b064-1a9d43ac40c5] to /home/browni/.julia/compiled/v1.7/DiffResults/jl_ixnUlq.
Stacktrace:

Thanks

This has nothing to do with your own code, you have something broken in your package installation. What version of Julia are you using? What version of Symbolics (type status at the pkg> prompt).

I am using IJulia with kernel Julia 1.7.3

This is the status of packages in my environment:

      Status `~/LasthrimProjection/JupyterLab/DynamicalSystems/Project.toml`
  [91a5bcdd] Plots v1.35.5
  [24249f21] SymPy v1.1.7
  [0c5d862f] Symbolics v4.13.0

Works fine for me with Julia 1.8.2 and Symbolics 4.13.0.