JuliaLang / JuliaLang/LinearAlgebra.jl

Update Docs for Cross Product of Complex Numbers

Open
#642 13 comments 0 reactions 0 assignees View on GitHub
docs
Dominant language
Julia
Stars
77
Forks
65
Avg merge
3d 23h
Merged PRs (30d)
10

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the supplied Julia 1.0.3 example, focusing on LinearAlgebra.cross, dot, and the complex-vector convention. Check the existing documentation for these entry points and determine whether the reported conjugation is expected; done means the docs clearly state the behavior and include a correct complex example.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.