josdejong / josdejong/mathjs

Failed Special Boundary Tests with math.log()

Open
#1,277 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
JavaScript
Stars
15.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Hello all,

I've written some special boundary tests for the math.log(x,b) function and found possible bugs. Some or all of these may be trivial ones and some might not be bugs at all. Either way just thought it would bring it to your attention.

From the code, I understood that when two int parameters are entered into the function the answer is calculated by dividing log(number)/log(base). so log(x,b) = log(x)/log(b). This may then point to bugs in the division function. The special boundary tested for both parameters was x >=0. Since that is what an if statement in the overloaded log (x) function checks for.

Attached is my code for the test I wrote with Jest: https://jestjs.io/

General Information -

Version: 5.2.0 (Production)
Reproduction Steps:

-Run the function with the same inputs in a js file attached to an HTML document

OR

-To run the test suite... [code.zip]

  1. Install all needed libraries for node.js and jest
  2. Unzip the contents of the attached folder into a directory
  3. Open the terminal
  4. cd into the directory with files
  5. run command: "sudo yarn test"

Severity: 4 - trivial
Enviroment: Node.js

Bug Description -

First and last failed case -
Division of thesame logarithms sometime yeilds answers that are not an integer 1 (one).
log(0,0) = log(0)/log(0) = -Infinity/-Infinity = 1 but returns NaN
log(-1,-1) = log(-1)/log(-1) = 1.36i/1.36i = 1 (integer) but returns a complex object with real value of 1

2nd and 3rd failed case -
Division of a logarithm by a zero in some cases doesn't return NaN (since division by zero)
log(0,1) = log(0)/log(1) = -Infinity/0 = NaN but returns -Infinity
log(-1,1) = log(-1)/log(1) = 1.36i/0 = NaN but returns complex object with both imaginary and real values as Infinity

Results Report:

resultsreport

Contributor guide

Open the contributing guide

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.

Research direction

Run the attached Jest test suite from code.zip in the Node.js environment and inspect the math.log(x, b) entry point. Compare the reported boundary cases for zero, negative values, and base one with the project's intended behavior; done means the expected results are established and the failing cases are covered by passing regression tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.