# Should 1^x == 1?

**URL:** <https://discourse.julialang.org/t/should-1-x-1/77529>\
**Category:** Specific Domains\
**Tags:** symbolics\
**Created:** [March 7, 2022, 4:57pm UTC](https://discourse.julialang.org/t/should-1-x-1/77529 "2022-03-07T16:57:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_Pagnani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_pagnani/32/3136_2.png) [@Andrea\_Pagnani](https://discourse.julialang.org/u/Andrea_Pagnani)\
**Post date:** [March 7, 2022, 4:57pm UTC](https://discourse.julialang.org/t/should-1-x-1/77529/1 "2022-03-07T16:57:23Z")

</div>

Dearests,

```julia
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.

```julia
f[α_, p_, N_] := (p^α_ + 1 - p)^N
D[f[a, p, N], a]/(Log[p]) /. a -> 1 # returns N * p 

```

---

<div class="post-metadata">

**Author:** ![suavesito](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/suavesito/32/34386_2.png) [@suavesito](https://discourse.julialang.org/u/suavesito)\
**Post date:** [March 7, 2022, 6:49pm UTC](https://discourse.julialang.org/t/should-1-x-1/77529/2 "2022-03-07T18:49:31Z")

</div>

It might be a good idea. Other simplifications area already done by default (you can check them [here](https://symbolicutils.juliasymbolics.org/#simplification)).

I’ll add a PR for this.

---

<div class="post-metadata">

**Author:** ![Juan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan/32/7657_2.png) [@Juan](https://discourse.julialang.org/u/Juan)\
**Post date:** [March 7, 2022, 8:21pm UTC](https://discourse.julialang.org/t/should-1-x-1/77529/3 "2022-03-07T20:21:14Z")

</div>

What if x=∞ or -∞?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [March 7, 2022, 8:31pm UTC](https://discourse.julialang.org/t/should-1-x-1/77529/4 "2022-03-07T20:31:17Z")

</div>

`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`.)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 8, 2022, 1:37pm UTC](https://discourse.julialang.org/t/should-1-x-1/77529/5 "2022-03-08T13:37:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Andrea\_Pagnani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_pagnani/32/3136_2.png) [@Andrea\_Pagnani](https://discourse.julialang.org/u/Andrea_Pagnani)\
**Post date:** [March 8, 2022, 3:41pm UTC](https://discourse.julialang.org/t/should-1-x-1/77529/6 "2022-03-08T15:41:56Z")

</div>

Done!

[Issue #437](https://github.com/JuliaSymbolics/SymbolicUtils.jl/issues/437#issue-1162808282) on SymbolicsUtils.

Thanks  
A

---

<div class="post-metadata">

**Author:** ![Andrea\_Pagnani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_pagnani/32/3136_2.png) [@Andrea\_Pagnani](https://discourse.julialang.org/u/Andrea_Pagnani)\
**Post date:** [September 7, 2022, 9:51am UTC](https://discourse.julialang.org/t/should-1-x-1/77529/7 "2022-09-07T09:51:54Z")

</div>

Made pull request [PR #469](https://github.com/JuliaSymbolics/SymbolicUtils.jl) at SymbolicUtils.jl
