Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

imag function for type Polynomial

Open
#584 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
julia
Domain
backend

Research direction

Run the Julia MWE in the issue to reproduce the missing imag(::Polynomial) method, then inspect how the existing real and conj methods are defined in Polynomials.jl. Done means imag(p) works for the demonstrated complex polynomial with behavior analogous to those methods.

Written by the indexing model from the issue text.

Description

Hi, is there a reason real and conj are defined for the type Polynomial but imag is not? If no reason not to, I can make a PR defining the analogous functions. As a MWE, the real, and conj calls work, but imag is not defined.

using Polynomials
p = Polynomial((6,3,3.0+1im))
real(p)
conj(p)
imag(p)
ERROR: MethodError: no method matching imag(::Polynomial{ComplexF64, :x})

Closest candidates are:
  imag(::Missing)
   @ Base missing.jl:101
  imag(::LinearAlgebra.UnitLowerTriangular)
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/triangular.jl:160
  imag(::LinearAlgebra.UnitUpperTriangular)
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/triangular.jl:161
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[5]:1

Thanks!

Dominant language
Julia
Stars
321
Forks
81
Avg merge
10h 1m
Merged PRs (30d)
5

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaMath/Polynomials.jl

All issues in JuliaMath/Polynomials.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.