Riemann Zeta Function Implemented
I implemented the original version of this issue without the Riemann Siegel Formulation for the critical strip. It includes the analytic continuation using Riemann's Functional Equation. All tests are passing with Real, Complex and Irrational numbers. Please let me know if I need to add or change anything.
I pushed out a new one with Big Number support and all of the changes listed above. All tests are passing and docs have been added too.
For some reason I cant comment on the review. I think leaving the file names as riemannZeta and having the actual name to be just zeta would be better in the case of future versions implementing other zeta functions. If this is inconsistent to the other function then I can certainly change it. Also, I think you may have reviewed an older commit for the embedded docs since I have added those. The types have been updated too. The BigNumber aliases can be removed and reuse code if you think that is a better idea than duplicating the code for BigNumbers. I'm still fairly new to PRs so I apologise if I did something wrong with updating/fixing my code with GitHub
Thanks for all the updates. I think we're about there. I made two more small remarks just to make sure we're on the same page.
For some reason I cant comment on the review.
hm that is odd. Maybe I wrongly created a second review with the second round of feedback, closing the first or so.
I think leaving the file names as
riemannZetaand having the actual name to be justzetawould be better in the case of future versions implementing other zeta functions. If this is inconsistent to the other function then I can certainly change it.
I strongly prefer to keep the name of the actual function consistent with the names of the source files. I understand your reasoning but I think it will lead to confusion about whether riemannZeta is the same as zeta or not if they are mixed. Other future versions of zeta will simply have to pick a other, unique name like hurwitzZeta.
Alright that makes sense to me, I'll rename the source files and add the changes you requests possibly over the weekend
I see one unit test fails: https://github.com/josdejong/mathjs/actions/runs/5057022868/jobs/9149909403?pr=2950
Error: Required dependency "BigNumber" missing for factory "zeta" (suffix: Number)
I guess that is because in the number-only implementation of mathjs factoriesNumber.js, BigNumber does not exist. This can be solved in two ways:
- Make the dependency optional, like
'?BigNumber'and add a check before using it to see whether it is defined. - Rewrite the code so you don't need the
BigNumberimport: you can make zero by multiplying a variable from which you know it is a BigNumber by zero. You can create a BigNumber n by doingzero.add(n)wherezerois a BigNumber, etc.
How would I create a BigNumber of zero if I can't import the BigNumber though? Or is there a universal zero variable?
// given that x is a BigNumber:
const zero = x.times(0)
const bn = zero.plus(n)
I understand that, but how would I create x in the first place? I'm quite new to this so I apologize if this is a basic question
Ok, I renamed all the files to zeta, updated the ts types, and I added a more descriptive explanation for s. I just need your help fixing the BigNumber in build-test.
Ok, I renamed all the files to zeta, updated the ts types, and I added a more descriptive explanation for
s. I just need your help fixing the BigNumber in build-test.
Thanks for the updates. No problem at all. Getting BigNumbers right requires some effort: we need to be careful not accidentally throwing away precision by mixing numbers into the equation, and also we need to be careful to respect the configured precision, and use pi with the right precision etc.
Zooming a bit out I see we basically have two implementations: for real numbers and for complex numbers. The real number implementation is currently named zetaBigNumber and still a bit hard coded for BigNumbers, but we can make it a really generic function that accepts both number and BigNumber. It may be good to put the real number implementation in a separate file (for internal use), and use that in the zeta implementation. In the number-only version of mathjs (factoriesNumber.js) we could refer to this generic implementation since it works fine with just numbers. Does that make sense?
If you want we can make this PR a joint effort, I can do this last step of refining the BigNumber implementation if you like.
That would be fine with me! Do I need to change anything in order for you to modify the code in the pr?
OK let's do that, I'll create a new feature branch from yours and work out the last details of the BigNumber implementation. I'll keep you posted.
Closing in favor of #2975