Platform
Resources
Pricing
Sign in
Get started
Nicola
Working to decentralize the web
Workspace
Fork
Published
By
Nicola
Edited
Oct 15, 2020
Insert cell
md
`# ExtrapolateCumSumRatio`
Insert cell
ExtrapolateCumSumRatio
(
1000
,
1e15
,
{
PositionEstimate
:
4e6
,
VelocityEstimate
:
0
}
,
{
PositionEstimate
:
1
,
VelocityEstimate
:
0
}
)
===
4e9
Insert cell
ExtrapolatedCumSumRatioEpsilon
=
BigInt
(
302231454903657293676544
)
Insert cell
Ln
=
(
v
)
=>
Math
.
log
(
10
+
v
.
toString
(
)
)
Insert cell
function
ExtrapolateCumSumRatio
(
delta
,
relativeStart
,
estimateNum
,
estimateDenom
)
{
const
deltaT
=
delta
<<
128
const
t0
=
relativeStart
<<
128
const
position1
=
estimateNum
.
PositionEstimate
const
position2
=
estimateDenom
.
PositionEstimate
const
velocity1
=
estimateNum
.
VelocityEstimate
const
velocity2
=
estimateDenom
.
VelocityEstimate
const
squaredVelocity2
=
(
velocity1
*
velocity2
)
>>
128
if
(
squaredVelocity2
>
ExtrapolatedCumSumRatioEpsilon
)
{
let
x2a
=
(
(
t0
*
velocity2
)
>>
128
)
+
position2
let
x2b
=
(
(
deltaT
*
velocity2
)
>>
128
)
+
x2a
x2a
=
Ln
(
x2a
)
// Q.128
x2b
=
Ln
(
x2b
)
// Q.128
let
m1
=
x2b
-
x2a
m1
=
velocity2
*
position1
*
m1
// Q.128 * Q.128 * Q.128 => Q.384
m1
=
m1
>>
128
let
m2L
=
(
x2a
-
x2b
)
m2L
=
position2
*
m2L
// Q.128 * Q.128 => Q.256
let
m2R
=
velocity2
*
deltaT
// Q.128 * Q.128 => Q.256
let
m2
=
m2L
+
m2R
m2
=
velocity1
*
m2
// Q.256 => Q.384
m2
=
m2
>>
128
//Q.384 => Q.256
return
(
m1
+
m2
)
/
squaredVelocity2
// Q.256 / Q.128 => Q.128
}
let
halfDeltaT
=
deltaT
>>
1
// Q.128 / Q.0 => Q.128
let
x1m
=
velocity1
*
(
t0
+
halfDeltaT
)
// Q.128 * Q.128 => Q.256
x1m
=
x1m
>>
128
// Q.256 => Q.128
x1m
=
position1
+
x1m
let
cumsumRatio
=
(
x1m
*
deltaT
)
// Q.128 * Q.128 => Q.256
cumsumRatio
=
(
cumsumRatio
/
position2
)
// Q.256 / Q.128 => Q.128
return
cumsumRatio
}
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ExtrapolatedCumSumRatioEpsilon
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Ln
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ExtrapolateCumSumRatio
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML