Skip to content

Update Docs for Cross Product of Complex Numbers #642

@jsgraber

Description

@jsgraber

Version Info:
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, broadwell)
Environment:
JULIABOX = true
JULIA_PKG_SERVER = https://pkg.juliacomputing.com
JULIA = /opt/julia-0.6/bin/julia
JULIA_KERNELS = ['julia-0.6', 'julia-1.0', 'julia-1.0k']
JULIA_PKG_TOKEN_PATH = /mnt/juliabox/.julia/token.toml
JULIABOX_ROLE =
JULIA_NUM_THREADS = 4

When taking the cross-product of 2 complex 3-vectors, Julia returns the complex-conjugate of the correct answer.

To understand the problem, first 2 facts:
1.) the dot product of any vector with itself should be the magnitude of that vector squared. Thus dot(x,x) = norm(x)^2
2.) the cross product should return a vector which is perpendicular to the input vectors.
3.) the dot product of perpendicular vectors should be zero. Thus, if z = cross(x,y) then dot(z,x) should be zero.

The following code shows that Julia properly takes the dot product of complex numbers, but does not take the cross product properly. It also shows that it returns the complex conjugate of the correct cross product. To use the complex function provided by Julia, you must first take the complex conjugate of both input vectors:

using LinearAlgebra
x = [1 + 2im, 2 + 1im, 3 - 1im]
y = [3 - 1im, 2 - 2im, 4 + 1im]
dot_xy = dot(x,y)
dot_xx = dot(x,x)
cross_xy = cross(x,y)
cross_xy_prime = cross(conj.(x),conj.(y))
println("dot(x,x) = ", dot_xx)
println("norm(x)^2 = ", norm(x)*norm(x))
println("dot(x,y) = ", dot_xy)
println("cross(x,y) = ", cross_xy)
println("cross(x',y') = ", cross_xy_prime)
println("dot(x,cross(x,y)) = " , dot(x,cross_xy))
println("dot(x,(cross(x,y)')) = ", dot(x,cross_xy'))
println("dot(x, cross_xy_prime) = ", dot(x, cross_xy_prime))

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions