Skip to content

math.complex: fix log(), replace tests#25863

Merged
spytheman merged 2 commits into
vlang:masterfrom
tankf33der:math_complex_log
Nov 30, 2025
Merged

math.complex: fix log(), replace tests#25863
spytheman merged 2 commits into
vlang:masterfrom
tankf33der:math_complex_log

Conversation

@tankf33der

Copy link
Copy Markdown
Contributor

Incorrect handling of WolframAlpha parameters and mathematical notation led to the error not being detected during development and testing.

Some systems have the base as the first parameter of the function.

vlang has it second:
image

Great mpmath has it second too and with correct formula:
image

But WolframAlpha has it first:
image

Had to remove all current tests and replace them with one that is consistent with cmath from the Python distribution and the mpmath library.

p.s. I wrote tests for the entire complex module against complex.h file for the functions that match, and other functions are awaiting their turn for manual testing.

@tankf33der

tankf33der commented Nov 30, 2025

Copy link
Copy Markdown
Contributor Author

I will handle this errors.

@tankf33der

tankf33der commented Nov 30, 2025

Copy link
Copy Markdown
Contributor Author

The test showed that comparing f64 using == is a bad idea, which is natural and would depend on the system. Therefore, this also needs to be replaced in the future.

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find. Thank you @tankf33der 🙇🏻 .

@spytheman spytheman merged commit e07eb54 into vlang:master Nov 30, 2025
80 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants