JuliaSymbolics / Symbolics.jl

Symbolic programming for the next generation of numerical software
https://docs.sciml.ai/Symbolics/stable/
Other
1.37k stars 153 forks source link

`Differential`s display differently in a REPL than their docstring indicates they should #1076

Open LilithHafner opened 8 months ago

LilithHafner commented 8 months ago

From the docstring,

help?> Differential
search: Differential

  struct Differential <: Symbolics.Operator

  Represents a differential operator.

  Fields
  ≡≡≡≡≡≡

    •  x: The variable or expression to differentiate with respect to.

  Examples
  ≡≡≡≡≡≡≡≡

  julia> using Symbolics

  julia> @variables x y;

  julia> D = Differential(x)
  (D'~x)

But in a REPL, I get a different result

julia> using Symbolics

julia> @variables x y;

julia> D = Differential(x)
(::Differential) (generic function with 3 methods)

julia> D(y) # Differentiate y wrt. x
Differential(x)(y)

julia> Dx = Differential(x) * Differential(y) # d^2/dxy operator
Differential(x) ∘ Differential(y)

julia> D3 = Differential(x)^3 # 3rd order differential operator
Differential(x) ∘ (Differential(x) ∘ Differential(x))

Strangely, the REPL docstring example is a doctest. I'm happy to change the docstring and/or the show behavior so that these align.

ChrisRackauckas commented 8 months ago

The docstring is just really old. Interesting the doctest doesn't fail.