Closed ghost closed 8 years ago
This sort of thing happens frequently; I've backpedaled on this unit test a number of times due to precision errors.
Does using the first polyfill of Math.sinh
here work, which makes two Math.exp
calls?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh
If not, then we can look into relaxing this unit test, or modifying it to only look at a certain number of sig figs.
Thanks for looking into this!
I have tried both polyfils and they both have same issue. so what should we do ?
when i tried taylor method its working in browser for maximum value and passing tests. but at end test are not going to finish. console looks like that it is freezed public static 'sinh(D)D'(thread: JVMThread, d_val: number): number { var returning = d_val, xToN = dval, factorial = 1, index = 1, nextTerm = 1; while ( nextTerm != 0 ) { index++; factorial = index; index++; factorial = index; xToN = d_val_d_val; nextTerm = xToN/factorial; returning += nextTerm; }
return returning;
}
Yeah, definitely don't do anything crazy. Let me look into it to see if I can restrict Java to printing only a specific number of sigfigs.
Thanks :) Actually these two sig figs tests are problem for sinh, tanh, expm1, log1p because there polyfill uses Math.exp which eventualy results to 1 ...
@owaishanif786 I looked into it. You should just add checks in your loop to continue
when the value is Double.MAX_EXPONENT
or Double.MIN_EXPONENT
. It looks like those are causing your issues, which makes sense given the use of Math.exp
in the polyfill. :) (We already do this for a few functions in StrictMathTest.java
)
Also, you should implement a polyfill for Math.sinh
in src/util.ts
, just after Math.imul
. Then, define the native using Math.sinh
. We want to use the browser's version of this function if available, since it will be faster (and probably more accurate on these corner cases).
Once you've done that and the tests pass, please open a PR with your change!
Your code is merged, so this is all set. Thanks for your contribution!
I have just tried to implement Math.sinh but when i ran tests it's giving me problem
point 7,8 value mismatch in doppio and java i have not much experience with these precision type details but if any one can suggest how to solve this problem or from where to get help or any clue how to solve this. Thanks