abs2

abs2(x)

Squared absolute value of x

Examples

  1. Calculate the absolute square of a real number:

    julia> abs2(-5)
    25

    This example calculates the absolute square of -5, resulting in 25.

  2. Calculate the absolute square of a complex number:

    julia> abs2(3 + 4im)
    25

    It computes the absolute square of the complex number 3 + 4im, which evaluates to 25.

  3. Compute the absolute square of a floating-point number:
    julia> abs2(2.5)
    6.25

    This example demonstrates the calculation of the absolute square of a floating-point number, yielding 6.25.

Common mistake example:

julia> abs2("Hello")
ERROR: MethodError: no method matching abs2(::String)

In this example, the abs2 function is applied to a string which is not a valid input type. It is important to provide a valid argument type such as real numbers or complex numbers to abs2 in order to avoid this error.

See Also

abs2, beta, binomial, ceil, cell, cross, ctranspose, ctranspose!, cummin, cumprod, cumprod!, cumsum, cumsum!, cumsum_kbn, div, divrem, eigfact, eigfact!, eigmin, eps, erf, erfc, erfcinv, erfcx, erfi, erfinv, exp, exp10, exp2, expm1, exponent, factor, factorial, factorize, floor, gcd, invmod, log, log10, log1p, log2, logspace, max, min, mod, mod1, modf, next, nextpow, nextprod, num, primes, primesmask, prod, realmin, sqrt, sum!, sumabs, sumabs!, sumabs2, sumabs2!,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: