Since Symbolics.jl does not have integrate command, I am using Reduce.jl to do the integration.
Reduce works ok when passing the integrand as literal expression in the command itself as follows
:(int(sin(x),x)) |> rcall
But when putting the integrand in a variable first, and then using this variable inside the call, it does not work. I tried using eval() but Julia hanged.
Here is a complete MWE
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.7.1 (2021-12-22)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using Reduce
julia> :(int( sin(x),x)) |> rcall
:(-(cos(x)))
Works fine. But I wanted to make the integrand a variable.
julia> using Symbolics
julia> @variables x
julia> integrand = sin(x)
julia> :(int( integrand ,x)) |> rcall
:(integrand * x)
Which means it did not see the variable integrand from outside. So I tried adding eval around it
julia> :(int( eval(integrand) ,x)) |> rcall
But now Julia hanged.
These two packages have to work together better otherwise If I can't use variables from outside Reduce package in the commands inside Reduce, this will make it very limited to use. For example, I wanted to build some symbolic expressions using Symbolics and then use them in integrate command in Reduce package.
Is there a way around this?
I do know that the x used by Symbolics and the x used by Reduce are different. For example, from fresh Julia session, I can type first thing
:(int(sin(x),x)) |> rcall
And it works, without having to use @variables x first. It looks like Reduce uses it own symbolic symbols without the need to declare them first.
But to build a symbolic expression with x outside Reduce, one needs to first use @variables x. This could be the cause the problem. I do not know.