Skip to content

(-csch[x]^2)^(1/2) gives ERROR: DomainError with -csch with symbolics #719

@nasser1

Description

@nasser1

For reference: https://stackoverflow.com/questions/73522774/how-to-translate-cschx21-2-to-julia-symbolic-error-domainerror-with

I am adding this as issue just in case it is new.

>julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.0 (2022-08-17)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Symbolics

julia> @syms x
(x,)

julia> (-csch(x)^2)^(1//2)
ERROR: DomainError with -1.0:
Exponentiation yielding a complex result requires a complex argument.
Replace x^y with (x+0im)^y, Complex(x)^y, or similar.
Stacktrace:
 [1] throw_exp_domainerror(x::Float64)
   @ Base.Math ./math.jl:37
 [2] ^(x::Float64, y::Float64)
   @ Base.Math ./math.jl:1003
 [3] ^
   @ ./promotion.jl:422 [inlined]
 [4] ^
   @ ./rational.jl:481 [inlined]
 [5] unstable_pow
   @ ~/.julia/packages/SymbolicUtils/qulQp/src/types.jl:801 [inlined]
 [6] ^(a::SymbolicUtils.Mul{Number, Int64, Dict{Any, Number}, Nothing}, b::Rational{Int64})
   @ SymbolicUtils ~/.julia/packages/SymbolicUtils/qulQp/src/types.jl:1047
 [7] top-level scope
   @ REPL[3]:1

julia> 


However this works

julia> sqrt((-csch(x)^2))
sqrt(-(csch(x)^2))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions