<p>Many languages like R, Julia, and Python store imaginary numbers as a complex number with a 0 valued real component. We may see this with the following R code:</p>
<pre><code>I_x &lt;- 3i
C_y &lt;- Inf + 2i
z &lt;- I_x * C_y
</code></pre>
<p>If R had a datatype for imaginary numbers, <code>z</code> would equal <code>-6 + Infi</code>, but the result is <code>NaN + Infi</code> because the imaginary is implemented by a complex number with a zero real component (<code>3i</code> is <code>0 + 3i</code>) so a NaN arises from the multiplication of the <code>0</code> component by <code>Inf</code>.</p>
<p>A <a href="https://langdev.stackexchange.com/questions/3508/what-programming-languages-contain-a-built-in-imaginary-data-type#comment10014_3509">commenter notes</a> that languages may special-case the multiplication of two complex numbers together, so another test case which would discriminate that could be to see the result of (in R) <code>Inf * 1i</code> which results in <code>NaN + Infi</code>.</p>
<p>My question is, <em>which languages provide a built-in imaginary data type which is <strong>not</strong> implemented as a complex type with a 0 valued real component</em>? A good answer should show the output to the above or an equivalent test case or point to language documentation. There will probably be multiple good answers.</p>
<p>To be specific, I am looking for languages with <strong>built-in</strong> types, not the <a href="https://stackoverflow.com/questions/72157051/is-it-possible-to-define-a-purely-imaginary-type-in-haskell">capacity to create imaginary types</a> or libraries which can be downloaded and provide these types.</p>

<types><language-comparison><math>
What programming languages contain a built-in imaginary data type?
CC BY-SA 4.0
2024-02-03T04:00:21.997Z
refer to https://www2.eecs.berkeley.edu/Pubs/TechRpts/1992/CSD-92-667.pdf
Moonchild
CC BY-SA 4.0
2024-02-03T08:28:41.210Z
Does this issue actually occur for normal operands, i.e. without `inf` or `nan`?
MisterMiyagi
CC BY-SA 4.0
2024-02-03T10:47:07.753Z
Frame challenge: I'm not sure that complex numbers with separate inf/nan components should be considered as legitimate in the first place. In mathematics, complex analysis uses the concept of "complex infinity" which is a complex number of "infinite" magnitude and indeterminate angle (as well as "directed infinities" that are the positive-infinitely scaled version of some finite complex number). Complex numbers should theoretically be untouched by converting from rectangular to polar and back; infinities throw a wrench in that.
Karl Knechtel
CC BY-SA 4.0
2024-02-03T12:58:28.763Z
Are you interested in libraries that _come with_ the language or not?  These fall between your terms "built-in" and "downloadable".  I'm particularly thinking of C++ and C support for complex numbers in their respective Standard libraries.
Toby Speight
CC BY-SA 4.0
2024-02-03T18:14:27.233Z
@KarlKnechtel I agree what you said is more useful. But converting from rectangular to polar and back is very much like log and pow. It's difficult to say a type good for storing logarithms is useless all the times.
user23013
CC BY-SA 4.0
2024-02-03T20:08:12.350Z
@TobySpeight "Are you interested in libraries that come with the language or not?" Yes. I realize I was not exactly clear. If the standard library for a language provides this feature, then I want to know about it.
Adam Hyland
CC BY-SA 4.0
2024-02-05T18:30:02.463Z
Infinity times i is not an imaginary number or a complex number, so you cannot rely on such a test because the language might simply not allow multiplying a complex (or imaginary) number by infinity. You can have the complex numbers plus a point at infinity (a space called the Riemann sphere), or the complex numbers plus many points at infinity if you wish, but these are different types of number to "complex".
kaya3
CC BY-SA 4.0
2024-02-05T18:33:08.203Z
There's also the matter of interpretation; if I declare `type Imaginary = number;` in TypeScript, for example, does this type represent an imaginary number? It supports binary `+`, unary and binary `-`, and multiplication by real numbers, which are the only arithmetic you can do with imaginary numbers. Sure, if you use binary `*` on two such "imaginary" numbers you'll get a nonsense answer, but that's only because binary `*` itself doesn't make sense within the space of imaginary numbers.
kaya3
CC BY-SA 4.0
2024-02-05T18:42:02.547Z
@kaya3 How do you propose I word a question to discriminate between languages which returns "-6 + Infi" vs. "NaN + Infi" for the above test?
Adam Hyland
CC BY-SA 4.0
2024-02-05T18:48:46.990Z
@AdamHyland If a language returns either of those things then it's not a true complex number type, in the mathematical sense, since neither of those are complex numbers.
kaya3
CC BY-SA 4.0
2024-05-01T09:13:43.797Z
None of these mentioned in the OP's post really implement _complex_ numbers, because they do not implement _real_ numbers in the first place, only floating point numbers... Floating point addition is not even associative.
xuq01
<h1>Reference</h1>
<p><a href="https://en.wikipedia.org/wiki/Complex_data_type" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Complex_data_type</a></p>
<h1>Some Examples</h1>
<h3>Maxima</h3>
<p><strong>Maxima</strong>: This language provides extensive support for complex and imaginary number arithmetic, featuring functions like <code>cabs</code> for the magnitude of complex numbers and <code>rectform</code> to express complex numbers in rectangular form. Similar to Wolfram Language, Maxima can handle operations involving infinities within the complex number system.</p>
<p><a href="https://tio.run/##hZHNboMwEITvPMUqUiR@GkUQTuHYXnpqqlTqsaKJ066KgRpbTXh5urYxkAapNzyeGX/L8vyMPO@6dQgP7IQlg0PF64KdoVT8nYkGwrXXxrCFDUSQhkvMvDahYwwrSMzRo@z9VQhygfKTM4kHHW8UpwCVRNAmmVeL6qgO0kqhkb5VJZGVvbY2mq7dI9Xi6QKCNaqQBqYh7c1WnlRRiFxqxSclyACAUgksUcPCYB@fnEZ6VccoFZuJdHSITbCmOScHFvJJyVpJaCwrsuOUthZYSn@xHy/3im9hcQdujiCbMe0s2mgcWGfMzz3P6P5D@FqJLyw/4Ie2AljSmlFeNJ373hWqoSHpSP/Nd5umtDO8IGe9gy701uKr4d3ENy/0tI9OqvVL/iZKMTC40/86pQloK1RviVK70A3MNUqD9k@l4e879YDUt4I0MP26tet@AQ" rel="nofollow noreferrer">Try it online!</a></p>
<pre><code>/* Define complex numbers */
z1 : 3 + 4*%i;
z2 : 1 - 2*%i;

/* Complex number arithmetic */
sum : z1 + z2;
product : z1 * z2;
quotient : z1 / z2;

/* Simplify results */
simp_sum : fullratsimp(sum);   /* 2 %i + 4  */
simp_product : fullratsimp(product);  /* 11 - 2 %i  */
simp_quotient : fullratsimp(quotient);

/* Output simplified results */
print(&quot;Simplified Sum: &quot;, simp_sum);
print(&quot;Simplified Product: &quot;, simp_product);
print(&quot;Simplified Quotient: &quot;, simp_quotient);

/* Working with infinity */
infinityPlus : inf + (3 + 4*%i);
infinityTimes : inf*%i * z1;

/* Output results with infinity */
print(&quot;Infinity plus (3+4i): &quot;, fullratsimp(infinityPlus)); /* inf + 4 %i + 3  */
print(&quot;Infinity times (3+4i): &quot;, fullratsimp(infinityTimes)); /*  (3 %i - 4) inf   */
</code></pre>

CC BY-SA 4.0
2024-04-21T03:02:42.287Z
2024-04-25T23:43:36.857Z
2024-04-25T23:43:36.857Z
138 Aspen
CC BY-SA 4.0
2024-04-21T03:15:21.427Z
This answer mostly repeats what is in the *other* answers, but also without addressing the core question about languages with an imaginary type distinct from a complex number with zero real component.
Michael Homer
CC BY-SA 4.0
2024-04-21T03:18:34.773Z
I see that it's been edited quite dramatically in its history - there were probably some good points about C99 now removed as well. Maxima hadn't been mentioned previously, although as you say it's mostly within a complex number type (but the results of the test calculations from the question aren't given - those could help). I think editing it to give answers that aren't in the existing answers would help, including if those answers are mistaken about some relevant aspect of a language you do also mention.
Michael Homer
CC BY-SA 4.0
2024-04-21T18:09:47.330Z
Thank you for adding another example language with code!
Adam Hyland
<p>At least two languages of the C family provide complex numbers either built-in or as part of the standard library defined in the language specification.</p>
<h1>C</h1>
<p>The language has three built-in complex types: <code>double _Complex</code>, <code>float _Complex</code> and <code>long double _Complex</code> (unless the implementation defines <code>__STDC_NO_COMPLEX__</code>).  It may also have three imaginary types:
<code>double _Imaginary</code>, <code>float _Imaginary</code> and <code>long double _Imaginary</code>.</p>
<p>If the standard library header <code>&lt;complex.h&gt;</code> is included, simpler names for these are defined (<code>double complex</code>, <code>float complex</code> and <code>long double complex</code>, respectively), as well as a full set of mathematical functions on complex types analogous to those provided for floating-point numbers.</p>
<p>(<a href="https://www.open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf#%5B%7B%22num%22%3A116%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C-27%2C816%2Cnull%5D" rel="nofollow noreferrer">specification</a>)</p>
<p>I don't have an environment supporting pure imaginary numbers, only complex.  On this system, the test fails:</p>
<pre class="lang-c prettyprint-override"><code>#include &lt;complex.h&gt;
#include &lt;stdio.h&gt;
#include &lt;math.h&gt;

int main(void)
{
    double complex I_x = 3 * I;
    double complex C_y = INFINITY + 2 * I;
    double complex z = I_x * C_y;

    printf(&quot;%e%+e·i\n&quot;, creal(z), cimag(z));
}
</code></pre>
<pre class="lang-none prettyprint-override"><code>-nan+inf·i
</code></pre>
<p>However, it's conceivable that other C implementations produce different results if they provide the pure imaginary type.</p>
<h1>C++</h1>
<p>The C++ standard library defines a <code>complex&lt;T&gt;</code> template that can be used to create a complex version of any arithmetic type.  Similar to C, the standard header <code>&lt;complex&gt;</code> provides a full set of mathematical functions, generally with the same names as their scalar counterparts.  Pure imaginary numbers don't exist - they are represented by complex numbers with a zero real component.</p>
<p>Namespace <code>std::literals::complex_literals</code> provides suffix notation for literals of imaginary <code>double</code>, <code>float</code> or <code>long double</code> type.</p>
<p>(<a href="https://eel.is/c++draft/complex.numbers" rel="nofollow noreferrer">specification</a>)</p>
<p>This fails your test:</p>
<pre class="lang-cpp prettyprint-override"><code>#include &lt;complex&gt;
#include &lt;iostream&gt;
#include &lt;limits&gt;

int main()
{
    using namespace std::literals::complex_literals;
    auto Inf = std::numeric_limits&lt;double&gt;::infinity();
    auto I_x = 3i;
    auto C_y = Inf + 2i;
    auto z = I_x * C_y;

    std::cout &lt;&lt; z &lt;&lt; '\n';
}
</code></pre>
<pre class="lang-none prettyprint-override"><code>(-nan,inf)
</code></pre>

CC BY-SA 4.0
2024-02-03T23:06:23.437Z
2024-02-05T17:55:54.523Z
2024-02-05T17:55:54.523Z
Toby Speight
CC BY-SA 4.0
2024-02-07T19:24:31.377Z
I appreciate this detailed answer, even though the result is negative. Ideally this question will grow to have many answers and someone who finds it won't be left speculating about the performance of important languages like C and C++. Thank you.
Adam Hyland
<h1>Go</h1>
<p>Go has two built-in complex types: <code>complex64</code> and <code>complex128</code>, being a pair of <code>float32</code> and <code>float64</code> respectively. It also has <a href="https://go.dev/ref/spec#Imaginary_literals" rel="nofollow noreferrer">imaginary literals</a>, but all it does is return a complex number with a real value set to 0, so Go doesn't pass the tests in the OP.</p>
<pre class="lang-go prettyprint-override"><code>ix := 3i
cy := complex(0,math.Inf(1)) + 2i
z := ix * cy

fmt.Println(&quot;ix&quot;, ix) // ix (0+3i)
fmt.Println(&quot;cy&quot;, cy) // cy (0+Infi)
fmt.Println(&quot;z&quot;, z)   // z (-Inf+NaNi)
</code></pre>
<p><a href="https://ato.pxeger.com/run?1=m70oPX_BTfOCxOTsxPRUhdzEzDwurszcgvyiEgWltNwSJTgnN7EkQ4mLK600LxmsTENToXppaUmarsXNiswKBStbBeNMruRKECM5P7cgJ7VCw0AHpEnPMy9Nw1BTU0FbwSiTqwqkAKheSyG5EmhaboleQFFmXklOnoZSZoWSDlBKE1U0uRIomlyJJloFFKzShNi_sBZCL1gAoQE" rel="nofollow noreferrer">Attempt This Online!</a></p>
<p>There are 3 <a href="https://go.dev/ref/spec#Complex_numbers" rel="nofollow noreferrer">built-in functions</a> for complex numbers:</p>
<ul>
<li><code>complex(realPart, imaginaryPart floatT) complexT</code>: construct a complex number from a given pair of floats.</li>
<li><code>real(complexT) floatT</code>: get the real portion of a complex number.</li>
<li><code>imag(complexT) floatT</code>: get the imaginary portion of a complex number.</li>
</ul>
<p>There are also more functions available in the <a href="https://pkg.go.dev/math/cmplx" rel="nofollow noreferrer">math/cmplx</a> package.</p>

CC BY-SA 4.0
2024-02-07T04:34:01.180Z
2024-02-07T04:34:01.180Z
bigyihsuan
<p>Of the compiled programming languages, (I believe) it is Ada, C (but only some compilers), Chapel, and D.</p>

CC BY-SA 4.0
2024-05-01T04:27:13.143Z
2024-05-01T04:27:13.143Z
damianmoz
<p>Results are below:</p>
<h3>Languages</h3>
<p>Snap! and Ruby both pass the original test case, but Ruby does not pass a simpler one suggested by user23013.</p>
<p>Maple passes the original test case and user23013's other test case.</p>
<h4>Snap!</h4>
<p>The <a href="https://snap.berkeley.edu/" rel="nofollow noreferrer">Snap! programming language</a> is one example which will pass the above test case and return <code>-6 + Infi</code>. You can copy and play around with related code <a href="https://snap.berkeley.edu/snap/snap.html#present:Username=warped%20wart%20wars&amp;ProjectName=complex%20numbers&amp;editMode&amp;noRun" rel="nofollow noreferrer">here</a>.</p>
<p><a href="https://i.sstatic.net/N2obA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/N2obA.png" alt="Snap! building blocks showing definition of infinity and result of z value" /></a></p>
<h4>Ruby</h4>
<p>Ruby also has an imaginary type (<a href="https://onecompiler.com/ruby/423acpx2b" rel="nofollow noreferrer">run the code</a>):</p>
<pre><code># Define the complex numbers
three_i = Complex(0, 3)
infinity_plus_two_i = Complex(1.0/0.0, 2) # 1.0/0.0 creates Infinity in Ruby
# Perform the multiplication
result = three_i * infinity_plus_two_i
# Display the result
puts &quot;#{result}&quot;
</code></pre>
<p>Output is <code>-6.0+Infinity*i</code></p>
<p>A comment notes that this may be &quot;a special case for multiplying two complex numbers and &quot;Ruby gives <code>NaN+Infinity*i</code> for <code>Complex(0,1)*(1.0/0)</code> &quot;.</p>
<h4>Maple</h4>
<p><code>(infinity + 2*I) * 3*I</code> results in <code>-6 + infinity*I</code></p>
<p><code>(0 + I) * infinity</code> returns <code>infinity * I</code>, while <code>(0 + I) * (1/0)</code> produces a numeric error due to division by zero.</p>

CC BY-SA 4.0
2024-02-02T20:36:15.477Z
2024-02-06T19:15:48.260Z
2024-02-06T19:15:48.260Z
Adam Hyland
CC BY-SA 4.0
2024-02-02T21:58:05.943Z
Ruby gives `NaN+Infinity*i` for `Complex(0,1)*(1.0/0)`. It's probably a special case for multiplying two complex numbers instead of anything internally stored as imaginary.
user23013
CC BY-SA 4.0
2024-02-02T22:03:09.020Z
thanks for this! I'll update the question with this as a different test case.
Adam Hyland
<h2>Wolfram</h2>
<p>The programming language used by Mathematica not only supports pure imaginary numbers, but offers rigorous treatment of infinite complex values.</p>
<p><a href="https://www.wolframalpha.com/input?i2d=true&amp;i=%5C%2840%293+*+I%5C%2841%29+*+%5C%2840%29Infinity+%2B+2*I%5C%2841%29" rel="noreferrer"><code>(3 * I) * (Infinity + 2*I)</code></a></p>
<p>Wolfram considers that &quot;infinity + 2*i&quot; simply gives infinity, because in complex analysis, the finite imaginary component added to a real infinity just can't be preserved: either way, the result is a complex value with an infinite magnitude and an argument (angle, in the r-cis-theta sense) of zero.</p>
<p><a href="https://www.wolframalpha.com/input?i2d=true&amp;i=%5C%2840%29Infinity+*+%5C%2840%290+%2B+I%5C%2841%29%5C%2841%29" rel="noreferrer"><code>(Infinity * (0 + I))</code></a></p>
<p>Some syntax quirk on Wolfram Alpha seems to prevent multiplying real-infinity with <em>i</em> directly, but this way works.</p>
<p>It also recognizes a &quot;directed infinity&quot; concept (which I alluded to above): a complex value with an infinite magnitude and some known argument. As expected, multiplication by <em>i</em> effectively rotates by 90 degrees in the complex plane, and adding a finite offset has no effect:</p>
<p><a href="https://www.wolframalpha.com/input?i2d=true&amp;i=DirectedInfinity%5C%2891%291%2BI%5C%2893%29+*+I" rel="noreferrer"><code>DirectedInfinity[1+I] * I</code></a></p>
<p><a href="https://www.wolframalpha.com/input?i2d=true&amp;i=DirectedInfinity%5C%2891%291%2BI%5C%2893%29+%2B+1" rel="noreferrer"><code>DirectedInfinity[1+I] + 1</code></a></p>
<p>There's also a &quot;complex infinity&quot; concept representing the &quot;circle at infinity&quot; in complex analysis (some value with an infinite magnitude and unknown argument):</p>
<p><a href="https://www.wolframalpha.com/input?i2d=true&amp;i=ComplexInfinity+*+I" rel="noreferrer"><code>ComplexInfinity * I</code></a></p>
<p><a href="https://www.wolframalpha.com/input?i2d=true&amp;i=ComplexInfinity+%2B+1" rel="noreferrer"><code>ComplexInfinity + 1</code></a></p>

CC BY-SA 4.0
2024-02-03T11:11:48.147Z
2024-02-03T11:11:48.147Z
Karl Knechtel
# What programming languages contain a built-in imaginary data type?
Posted by: username_0 on 2024-02-02
Many languages like R, Julia, and Python store imaginary numbers as a complex number with a 0 valued real component. We may see this with the following R code:
I_x <- 3i
C_y <- Inf + 2i
z <- I_x * C_y

If R had a datatype for imaginary numbers, z would equal -6 + Infi, but the result is NaN + Infi because the imaginary is implemented by a complex number with a zero real component (3i is 0 + 3i) so a NaN arises from the multiplication of the 0 component by Inf.
A commenter notes that languages may special-case the multiplication of two complex numbers together, so another test case which would discriminate that could be to see the result of (in R) Inf * 1i which results in NaN + Infi.
My question is, which languages provide a built-in imaginary data type which is not implemented as a complex type with a 0 valued real component? A good answer should show the output to the above or an equivalent test case or point to language documentation. There will probably be multiple good answers.
To be specific, I am looking for languages with built-in types, not the capacity to create imaginary types or libraries which can be downloaded and provide these types.
**Tags:** types language-comparison math
> **Comments:**
> **username_1**: refer to https://www2.eecs.berkeley.edu/Pubs/TechRpts/1992/CSD-92-667.pdf  
> **username_2**: Does this issue actually occur for normal operands, i.e. without `inf` or `nan`?  
> **username_3**: Frame challenge: I'm not sure that complex numbers with separate inf/nan components should be considered as legitimate in the first place. In mathematics, complex analysis uses the concept of "complex infinity" which is a complex number of "infinite" magnitude and indeterminate angle (as well as "directed infinities" that are the positive-infinitely scaled version of some finite complex number). Complex numbers should theoretically be untouched by converting from rectangular to polar and back; infinities throw a wrench in that.  
> **username_4**: Are you interested in libraries that _come with_ the language or not?  These fall between your terms "built-in" and "downloadable".  I'm particularly thinking of C++ and C support for complex numbers in their respective Standard libraries.  
> **username_5**: @KarlKnechtel I agree what you said is more useful. But converting from rectangular to polar and back is very much like log and pow. It's difficult to say a type good for storing logarithms is useless all the times.  
> **username_0**: @TobySpeight "Are you interested in libraries that come with the language or not?" Yes. I realize I was not exactly clear. If the standard library for a language provides this feature, then I want to know about it.  
> **username_6**: Infinity times i is not an imaginary number or a complex number, so you cannot rely on such a test because the language might simply not allow multiplying a complex (or imaginary) number by infinity. You can have the complex numbers plus a point at infinity (a space called the Riemann sphere), or the complex numbers plus many points at infinity if you wish, but these are different types of number to "complex".  
> **username_6**: There's also the matter of interpretation; if I declare `type Imaginary = number;` in TypeScript, for example, does this type represent an imaginary number? It supports binary `+`, unary and binary `-`, and multiplication by real numbers, which are the only arithmetic you can do with imaginary numbers. Sure, if you use binary `*` on two such "imaginary" numbers you'll get a nonsense answer, but that's only because binary `*` itself doesn't make sense within the space of imaginary numbers.  
> **username_0**: @kaya3 How do you propose I word a question to discriminate between languages which returns "-6 + Infi" vs. "NaN + Infi" for the above test?  
> **username_6**: @AdamHyland If a language returns either of those things then it's not a true complex number type, in the mathematical sense, since neither of those are complex numbers.  
> **username_7**: None of these mentioned in the OP's post really implement _complex_ numbers, because they do not implement _real_ numbers in the first place, only floating point numbers... Floating point addition is not even associative.  
---
## 6 answers
### Answer by username_3 on 2024-02-03. Score: 8
## Wolfram

The programming language used by Mathematica not only supports pure imaginary numbers, but offers rigorous treatment of infinite complex values.

[`(3 * I) * (Infinity + 2*I)`](https://www.wolframalpha.com/input?i2d=true&i=%5C%2840%293+*+I%5C%2841%29+*+%5C%2840%29Infinity+%2B+2*I%5C%2841%29)

Wolfram considers that "infinity + 2\*i" simply gives infinity, because in complex analysis, the finite imaginary component added to a real infinity just can't be preserved: either way, the result is a complex value with an infinite magnitude and an argument (angle, in the r-cis-theta sense) of zero.

[`(Infinity * (0 + I))`](https://www.wolframalpha.com/input?i2d=true&i=%5C%2840%29Infinity+*+%5C%2840%290+%2B+I%5C%2841%29%5C%2841%29)

Some syntax quirk on Wolfram Alpha seems to prevent multiplying real-infinity with *i* directly, but this way works.

It also recognizes a "directed infinity" concept (which I alluded to above): a complex value with an infinite magnitude and some known argument. As expected, multiplication by *i* effectively rotates by 90 degrees in the complex plane, and adding a finite offset has no effect:

[`DirectedInfinity[1+I] * I`](https://www.wolframalpha.com/input?i2d=true&i=DirectedInfinity%5C%2891%291%2BI%5C%2893%29+*+I)

[`DirectedInfinity[1+I] + 1`](https://www.wolframalpha.com/input?i2d=true&i=DirectedInfinity%5C%2891%291%2BI%5C%2893%29+%2B+1)

There's also a "complex infinity" concept representing the "circle at infinity" in complex analysis (some value with an infinite magnitude and unknown argument):

[`ComplexInfinity * I`](https://www.wolframalpha.com/input?i2d=true&i=ComplexInfinity+*+I)

[`ComplexInfinity + 1`](https://www.wolframalpha.com/input?i2d=true&i=ComplexInfinity+%2B+1)
---
### Answer by username_0 on 2024-02-02. Score: 7
Results are below:
Languages
Snap! and Ruby both pass the original test case, but Ruby does not pass a simpler one suggested by user23013.
Maple passes the original test case and user23013's other test case.
Snap!
The Snap! programming language is one example which will pass the above test case and return -6 + Infi. You can copy and play around with related code here.

Ruby
Ruby also has an imaginary type (run the code):
# Define the complex numbers
three_i = Complex(0, 3)
infinity_plus_two_i = Complex(1.0/0.0, 2) # 1.0/0.0 creates Infinity in Ruby
# Perform the multiplication
result = three_i * infinity_plus_two_i
# Display the result
puts "#{result}"

Output is -6.0+Infinity*i
A comment notes that this may be "a special case for multiplying two complex numbers and "Ruby gives NaN+Infinity*i for Complex(0,1)*(1.0/0) ".
Maple
(infinity + 2*I) * 3*I results in -6 + infinity*I
(0 + I) * infinity returns infinity * I, while (0 + I) * (1/0) produces a numeric error due to division by zero.
> **Comments:**
> **username_5** (2024-02-02): Ruby gives `NaN+Infinity*i` for `Complex(0,1)*(1.0/0)`. It's probably a special case for multiplying two complex numbers instead of anything internally stored as imaginary.  
> **username_0** (2024-02-02): thanks for this! I'll update the question with this as a different test case.  
---
### Answer by username_8 on 2024-04-21. Score: 2
Reference
https://en.wikipedia.org/wiki/Complex_data_type
Some Examples
Maxima
Maxima: This language provides extensive support for complex and imaginary number arithmetic, featuring functions like cabs for the magnitude of complex numbers and rectform to express complex numbers in rectangular form. Similar to Wolfram Language, Maxima can handle operations involving infinities within the complex number system.
Try it online!
/* Define complex numbers */
z1 : 3 + 4*%i;
z2 : 1 - 2*%i;

/* Complex number arithmetic */
sum : z1 + z2;
product : z1 * z2;
quotient : z1 / z2;

/* Simplify results */
simp_sum : fullratsimp(sum);   /* 2 %i + 4  */
simp_product : fullratsimp(product);  /* 11 - 2 %i  */
simp_quotient : fullratsimp(quotient);

/* Output simplified results */
print("Simplified Sum: ", simp_sum);
print("Simplified Product: ", simp_product);
print("Simplified Quotient: ", simp_quotient);

/* Working with infinity */
infinityPlus : inf + (3 + 4*%i);
infinityTimes : inf*%i * z1;

/* Output results with infinity */
print("Infinity plus (3+4i): ", fullratsimp(infinityPlus)); /* inf + 4 %i + 3  */
print("Infinity times (3+4i): ", fullratsimp(infinityTimes)); /*  (3 %i - 4) inf   */
> **Comments:**
> **username_9** (2024-04-21): This answer mostly repeats what is in the *other* answers, but also without addressing the core question about languages with an imaginary type distinct from a complex number with zero real component.  
> **username_9** (2024-04-21): I see that it's been edited quite dramatically in its history - there were probably some good points about C99 now removed as well. Maxima hadn't been mentioned previously, although as you say it's mostly within a complex number type (but the results of the test calculations from the question aren't given - those could help). I think editing it to give answers that aren't in the existing answers would help, including if those answers are mistaken about some relevant aspect of a language you do also mention.  
> **username_0** (2024-04-21): Thank you for adding another example language with code!  
---
### Answer by username_4 on 2024-02-03. Score: 2
At least two languages of the C family provide complex numbers either built-in or as part of the standard library defined in the language specification.
C
The language has three built-in complex types: double _Complex, float _Complex and long double _Complex (unless the implementation defines __STDC_NO_COMPLEX__).  It may also have three imaginary types:
double _Imaginary, float _Imaginary and long double _Imaginary.
If the standard library header  is included, simpler names for these are defined (double complex, float complex and long double complex, respectively), as well as a full set of mathematical functions on complex types analogous to those provided for floating-point numbers.
(specification)
I don't have an environment supporting pure imaginary numbers, only complex.  On this system, the test fails:
#include 
#include 
#include 

int main(void)
{
    double complex I_x = 3 * I;
    double complex C_y = INFINITY + 2 * I;
    double complex z = I_x * C_y;

    printf("%e%+e·i\n", creal(z), cimag(z));
}

-nan+inf·i

However, it's conceivable that other C implementations produce different results if they provide the pure imaginary type.
C++
The C++ standard library defines a complex template that can be used to create a complex version of any arithmetic type.  Similar to C, the standard header  provides a full set of mathematical functions, generally with the same names as their scalar counterparts.  Pure imaginary numbers don't exist - they are represented by complex numbers with a zero real component.
Namespace std::literals::complex_literals provides suffix notation for literals of imaginary double, float or long double type.
(specification)
This fails your test:
#include 
#include 
#include 

int main()
{
    using namespace std::literals::complex_literals;
    auto Inf = std::numeric_limits::infinity();
    auto I_x = 3i;
    auto C_y = Inf + 2i;
    auto z = I_x * C_y;

    std::cout << z << '\n';
}

(-nan,inf)
> **Comments:**
> **username_0** (2024-02-07): I appreciate this detailed answer, even though the result is negative. Ideally this question will grow to have many answers and someone who finds it won't be left speculating about the performance of important languages like C and C++. Thank you.  
---
### Answer by username_10 on 2024-02-07. Score: 2
Go
Go has two built-in complex types: complex64 and complex128, being a pair of float32 and float64 respectively. It also has imaginary literals, but all it does is return a complex number with a real value set to 0, so Go doesn't pass the tests in the OP.
ix := 3i
cy := complex(0,math.Inf(1)) + 2i
z := ix * cy

fmt.Println("ix", ix) // ix (0+3i)
fmt.Println("cy", cy) // cy (0+Infi)
fmt.Println("z", z)   // z (-Inf+NaNi)

Attempt This Online!
There are 3 built-in functions for complex numbers:

complex(realPart, imaginaryPart floatT) complexT: construct a complex number from a given pair of floats.
real(complexT) floatT: get the real portion of a complex number.
imag(complexT) floatT: get the imaginary portion of a complex number.

There are also more functions available in the math/cmplx package.
---
### Answer by username_11 on 2024-05-01. Score: 1
Of the compiled programming languages, (I believe) it is Ada, C (but only some compilers), Chapel, and D.
---
