Formatting rules for Symbolic.arguments

Hi everyone. New to symbolic algebra in Julia and have a question about getting arguments from Symbolic.jl (using v. 6.41.0) expression. Is there any reason for the following differing formatting behavior in `Symbolics.arguments

@variables x
f1 = cos(x)
f2 = cos(x) + sin(x)
In: Symbolics.arguments(Symbolics.value(f1))
Out: 1-element SymbolicUtils.SmallVec{Any, Vector{Any}}:
  x
In: Symbolics.arguments(Symbolics.value(f2))
Out: 2-element SymbolicUtils.SmallVec{Any, Vector{Any}}:
  cos(x)
  sin(x)

Might be misunderstanding but the result for f1 is what I would expect from Symbolics.get_variables. What is the simplest way of obtaining cos(x) from Symbolics.arguments(Symbolics.value(f1)) ?

Thanks!

I’m guessing it interprets f2 as +(cos(x), sin(x))?

f1 is cos(x), so the argument of the function is x while its operator is cos. f2 is +(cos(x),sin(x)), so the operator is + and the arguments are [cos(x), sin(x)]

2 Likes

Thanks for the replies. Misunderstanding on my part!