Dearests,
using Symbolics
@variables p, α, N
D = Differential(α)
D((p^α + 1 - p)^N) / log(p) |> expand_derivatives |> x -> substitute(x, α => 1) |> simplify
correctly returns N*p*(1^(N - 1))
.
I was wondering if a substitution rule should be implemented such that 1^x -> 1
no matter what x
is. BTW, Mathematica does it automatically.
f[ α_, p_, N_] := (p^α_ + 1 - p)^N
D[f[a, p, N], a]/(Log[p]) /. a -> 1 # returns N * p
1 Like
It might be a good idea. Other simplifications area already done by default (you can check them here).
I’ll add a PR for this.
1 Like
1
is still a reasonable result. (math people think of it as an indeterminate form, but that tends to be less useful than defining it to equal 1
.)
2 Likes
Open an issue. Note that Symbolics is a typed symbolic system, so @variables p
is @variables p::Real
which is the “standard” type and can make these tricks. I forget the name, but it’s like @variables p::SafeReal
has different rule sets, for example omitting a/a == 1
, which is safe for the case of a=0
. The default is what users generally want, but the safe mode gives people a way to opt in to a slightly slower system that will work for all edge cases, giving the best of both worlds.
Done!
Issue #437 on SymbolicsUtils.
Thanks
A
Made pull request PR #469 at SymbolicUtils.jl