conj

conj(z)

Compute the complex conjugate of a complex number z

Examples

  1. Compute the complex conjugate of a complex number:

    julia> z = 3 + 4im;
    julia> conj(z)
    3 - 4im

    This example calculates the complex conjugate of the complex number z, which is 3 - 4im.

  2. Use the conj function with an array of complex numbers:

    julia> arr = [1 + 2im, 2 - 3im, 4 + 5im];
    julia> conj.(arr)
    3-element Array{Complex{Int64},1}:
    1 - 2im
    2 + 3im
    4 - 5im

    The conj. syntax applies the conj function element-wise to an array of complex numbers.

  3. Handle the conjugate of a real number:
    julia> x = 7;
    julia> conj(x)
    7

    When a real number is provided as input, the conj function simply returns the same value.

Common mistake example:

julia> z = 2 + 3im;
julia> conj(z, 4)
ERROR: MethodError: no method matching conj(::Complex{Int64}, ::Int64)

In this example, an additional argument is provided to the conj function, which is not supported. The conj function only takes a single argument, which should be a complex number.

See Also

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: