Comments (6)
Caused by #22 , I think.
If you revert back to bfb3349 , it works as expected:
new Decimal(1e9).slog(10).toString()
'1.9542425094393248'
new Decimal(10).tetrate(1.9542425094393248).toString()
'999999999.999996'
The reason why the new changes break this identity is that the old critical section for tetration is literally just exponentially increasing between its value at whole numbers, which isn't analytical in the slightest, just a decent enough approximation (it's monotonic and makes the number go up smooth-ish!).
The literature has advanced to the point, however, where exact values of tetrate and slog to continuous heights can be computed. At that point, we'd have everything we want, right? However, I don't know enough about advanced math to implement it in javascript.
I first had a friend plug http://tetration.itgo.com/pdf/TetrationSuperlog_Pages_22-27.pdf into Mathematica, to give me the values that you see in the table at https://github.com/Patashu/break_eternity.js/blob/master/break_eternity.js#L61 . For a set number of bases, I had the exact values of 0.1, 0.2, 0.3, etc. computed. And due to the way the critical section works, this means that 1.1, 2.1, 3.1... etc are also exactly computable.
BUT. Slogging 1e9^^1.5 doesn't land us exactly on one of our pre-computed values of slog, so we linearly interpolate between the two nearest values. This leads to losing precision, and a lot of it.
Later, I found a javascript implemented tetration calculator: http://myweb.astate.edu/wpaulsen/tetcalc/tetcalc.html
And it's fully open source (because, well, it's in your browser)! With just two issues, though. One is that it doesn't accept arbitrary bases, and the other is that it doesn't have slog. The former I could just be okay with (most people use 2, e or 10 as a base I would expect, and for others accepting less precision could be excepted). The latter means that no matter how closely I copy the calculator, I'd need to understand how to (or find) a slog calculator, or just pre-compute arbitrarily many values of the slog critical section and hope that it gets me enough precision somehow.
In general, I don't know if I'm smart enough to solve this problem, nor do I know what properties people want more (and which properties people are willing to sacrifice). Definitely curious to hear people's thoughts.
from break_eternity.js.
Oh, and to answer the other question, about Decimal(10).tetrate(1.5) - it DID previously spit out 1453, as you expected:
Old:
new Decimal(10).tetrate(1.5).toString()
'1453.0403018990432'
New:
new Decimal(10).tetrate(1.5).toString()
'300.2723103062356'
However, http://myweb.astate.edu/wpaulsen/tetcalc/tetcalc.html claims 10^^1.5 is 299.92012356854604298, so I think the new behaviour is closer to ground truth. Also curious as to your thoughts.
from break_eternity.js.
Hmmmm. Hey, I could make an arbitrarily good slog by admitting a number of iterations, and using newton's method (or similar) until we close in on the correct answer (according to however tetrate is calculated). Might do that.
from break_eternity.js.
Okay, that seems to work! Excellent.
Commit:
Unit test:
for (var i = 0; i < 1000; ++i)
{
let base = Math.random()*10;
let tower = Math.random()*10;
let round_trip = new Decimal(base).tetrate(tower).slog(base).toNumber();
if (Math.abs(round_trip - tower) > 1e10)
{
console.log(base, tower, round_trip)
}
}
The new slog runs at about 7e3 calls/s, which is slow, but it's at least slow and right. Open problem as to whether it can be made to converge faster (I bet it can if you're clever).
One last thing I want to do, investigate the tetration critical section to see if intermediate values can be a little more accurate.
from break_eternity.js.
Excellent, log-linear approximation-pow is much closer to the ground truth than just linear approximation.
Obviously better could be done (obviously the project of 'merge http://myweb.astate.edu/wpaulsen/tetcalc/tetcalc.html into break_eternity.js' remains open, e.g.) but this bugged me for a long time and I'm glad to finally look into it and prove that this simple improvement helps.
As always, let me know if you have any concerns, questions or suggestions.
from break_eternity.js.
I think everything works now, but feel free to re-open if you find a failing example.
from break_eternity.js.
Related Issues (20)
- equivalent to afford/sum geometric series for 'if the price exponentiates by a certain factor each purchase' HOT 1
- Bug? Missed cases with Add and multiply HOT 5
- Reduant constants? HOT 1
- `Decimal.ceil` is incorrect for very small positive numbers HOT 1
- Typescript CommonJS not exported properly HOT 2
- Documentation - Read.me - weirdy weirdo HOT 8
- Can't convert BigInt to Decimal without setting its value to 0 HOT 8
- different results when expexting the same result HOT 5
- `Decimal.lambertw("ee4992767175317001")` errors instead of returning a value HOT 1
- The next step HOT 5
- [enhancement] I think I’ve figured out how to do arbitrary-height super-roots. HOT 3
- Tetration/iteratedexp has incorrect behavior for large heights on small bases with large payloads HOT 2
- Wrong String for reciprocals HOT 1
- Wrong factorial approximation HOT 2
- `Decimal.lambertw` occasionally spikes with inputs around the ee31 range
- Unexpected NaN from sqrt()
- Decimal.isValid() ?
- `new Decimal("(e^x)1")` returns `Decimal` with fractional `layer` if `x` is not an integer
- `new Decimal("(e^x)1")` returns `Decimal` with negative `layer` if `x` is negative
- The normalization of `new Decimal(-Infinity)` breaks some operations and may be incorrect HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from break_eternity.js.