Skip to content

The real and the imaginary part are functions, Re and Im - #2185

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
the-real-and-imaginary-parts-are-functions
Oct 28, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
the-real-and-imaginary-parts-are-functions

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

The last part of #2145: the real and the imaginary part.

Names. On #2145 Happypig375 asked for the capitalised spelling. Checked against the sources, it is the written convention, and SymPy is the outlier:

Real part Imaginary part
ISO 80000-2, Wikipedia Re z Im z
Mathematica Re[z] Im[z]
Maple Re(z) Im(z)
SymPy re(z) im(z)
MATLAB, NumPy real(z) imag(z)

So Re(z) and Im(z) print as written there, and draw upright, \operatorname{Re}\left(z\right), as ISO writes them, rather than with the fraktur \Re. SymPy's re and im and MATLAB's real and imag are accepted on input, since those users type them. ToSympy emits sympy.re and sympy.im. The nodes are Entity.Ref and Entity.Imf, and they are also MathS.Re and MathS.Im.

What they do

  • Both are real: Im(3 + 4i) is 4, not 4i.
  • Both are real-linear, carried through sums, differences, and products and quotients by a real number. They are not carried through a product of two symbols, whose real part is Re(a) Re(b) - Im(a) Im(b), or through i, which turns one part into the other.
  • The conjugate keeps the real part and turns the imaginary one: Re(conj(z)) is Re(z), and Im(conj(z)) is -Im(z).
  • What is known to be real is its own real part, and has a value exactly where that has one: Re(abs(z)) is abs(z). Its imaginary part is not taken as 0. That is the lesson of The complex conjugate and the principal argument are functions #2181's BoundCheck finding: a codomain says what a node's values are, not where it has one, and Im(prime(x)) has no value at x = -3.
  • Both differentiate along the real line, Re(f)' being Re(f'). An equation in either is left unsolved, since where a part has a value is a line.

A change of reading. re(x) and im(x) were left as products since #733, while the library had neither function: two letters is short enough to be somebody's variable. They are the functions now, and the name without a bracket is still a variable. The breaking entry records it, and MissingFunctionNamesRefusedTest and SyntaxDocumentedTest now pin that the bare names stay variables. The MCP server's example of a silent product moves from im(z) to beta(z), and its misspelling hints for re and im are gone. Docs/Usage/Syntax.md's "Refused by name" paragraph, which still listed conjugate from before #2181, is corrected.

Input Was (2.6.0) Now
re(z) re * z Re(z)
im(3 + 4i), simplified (3 + 4i) * im 4
re * x re * x re * x

Measured

  • Suite: 17,361 passed, 0 failed, 13 skipped, on the code as pushed. The chain's own run had 2 failures, SyntaxDocumentedTest pinning re(x) and im(x) as products, which the amended commit's rows replace.
  • McpUnitTests 361, TerminalUnitTests 69, InteractiveWrapperUnitTests 19 passed.
  • Intbench chain against master 4fe3219: identical on every family, 0 moves. Performance gate passed on all 19 gated benchmarks.
  • Harnesses: BoundCheck 1208 shapes with the two new nodes and 0 disagreements, RootCheck 596/596, CasBench 120/121 with 0 wrong, SimpSweep 10463/10463, CrashCheck 2296 cases with 0 crashed, PropCheck and RuleCheck clean, CanonCheck (2091) and Confluence (3) matching their baselines.

Part of #2145. With this, every function #2145 asks for is in, and the unit-circle rewriting it mentions waits for #2148.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Re(z) and Im(z) are Entity.Ref and Entity.Imf, written as Mathematica, Maple and ISO 80000-2
write them, and accepted as SymPy's re and im and MATLAB's real and imag; they print Re and Im
and draw upright, \operatorname{Re}. Both are real, Im(3 + 4i) being 4 and not 4i, and
real-linear: carried through sums, differences, and products and quotients by a real number.
The conjugate keeps the real part and turns the imaginary one. Not through a product of two
symbols or through i, which mix the parts. What is known to be real is its own real part, and
has a value exactly where that has one; its imaginary part is not taken as 0, since a codomain
says what a node's values are and not where it has one. Both differentiate along the real line.

re and im were left as products while the library had neither, two letters being short enough
to be a variable's name. They are the functions now, and the name without a bracket is still a
variable; that change of reading is recorded as breaking. The MCP server's examples of a silent
product move to beta(z), and its misspelling hints for re and im are gone.

Part of #2145.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 28, 2026
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.52476% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.47%. Comparing base (4fe3219) to head (68ec3eb).

Files with missing lines Patch % Lines
...nuous/Evaluation.Continuous.Arithmetics.Classes.cs 79.31% 4 Missing and 2 partials ⚠️
...ources/AngouriMath/Core/Antlr/AngouriMathParser.cs 99.52% 1 Missing and 1 partial ⚠️
...ntinuous/Entity.Continuous.ComplexParts.Classes.cs 80.00% 2 Missing ⚠️
...ngouriMath/Functions/Continuous/Differentiation.cs 0.00% 0 Missing and 2 partials ⚠️
Sources/AngouriMath/Functions/Substitute.cs 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2185      +/-   ##
==========================================
+ Coverage   86.45%   86.47%   +0.01%     
==========================================
  Files         297      297              
  Lines       65448    65596     +148     
  Branches    19215    19224       +9     
==========================================
+ Hits        56582    56721     +139     
- Misses       4808     4811       +3     
- Partials     4058     4064       +6     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.03% <98.52%> (+0.01%) ⬆️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Sources/AngouriMath/Convenience/MathS.cs 90.03% <100.00%> (+0.06%) ⬆️
Sources/AngouriMath/Core/Antlr/AngouriMathLexer.cs 99.02% <100.00%> (+0.02%) ⬆️
Sources/AngouriMath/Core/Domains.Classes.cs 100.00% <100.00%> (ø)
...Math/Core/Transformations/Matching/MatchPattern.cs 86.03% <100.00%> (+0.06%) ⬆️
...nuous/Solvers/EquationSolver/InvertNode.Classes.cs 60.24% <100.00%> (+0.32%) ⬆️
...unctions/Output/Latex/Latex.Arithmetics.Classes.cs 97.36% <100.00%> (+0.04%) ⬆️
...ns/Output/ToString/ToString.Arithmetics.Classes.cs 100.00% <100.00%> (ø)
...ions/Output/ToSympy/ToSympy.Arithmetics.Classes.cs 72.22% <100.00%> (+1.06%) ⬆️
...s/AngouriMath/Functions/TreeAnalyzer/RealValued.cs 81.52% <ø> (ø)
...AngouriMath/Functions/TreeAnalyzer/Sort.Classes.cs 77.77% <100.00%> (+0.35%) ⬆️
... and 5 more

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit d44599f into master Oct 28, 2026
35 of 36 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 28, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the the-real-and-imaginary-parts-are-functions branch October 28, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant