-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
acosh(x).diff(x) == 1/(sqrt(x-1)*sqrt(x+1)) #23568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Hi, I am the SymPy bot (v167). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.11. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
Change looks good to me but failing test need to be looked into ! |
The failing tests are because changing the output of diff affects the heurisch algorithm. According to the linked issue, it's not clear if the failing integrals were even correct before. |
DLMF (https://dlmf.nist.gov/4.38) gives the derivative as
where the Is that equivalent to That seems to agree in all quadrants: In [59]: e1 = sign(re(z))/sqrt(z**2 - 1)
In [60]: e2 = 1/(sqrt(z-1)*sqrt(z+1))
In [61]: e1
Out[61]:
sign(re(z))
───────────
________
╱ 2
╲╱ z - 1
In [62]: e2
Out[62]:
1
───────────────────
_______ _______
╲╱ z - 1 ⋅╲╱ z + 1
In [63]: (e1 - e2).subs(z, 1+I).n()
Out[63]: -0.e-124 + 0.e-124⋅ⅈ
In [64]: (e1 - e2).subs(z, 1-I).n()
Out[64]: -0.e-124 - 0.e-124⋅ⅈ
In [65]: (e1 - e2).subs(z, -1+I).n()
Out[65]: -0.e-134 - 0.e-134⋅ⅈ
In [66]: (e1 - e2).subs(z, -1-I).n()
Out[66]: -0.e-128 + 0.e-125⋅ⅈ The formulas are perhaps consistent on the imaginary axis if In [83]: e1 = +1/sqrt(z**2 - 1)
In [84]: e2 = 1/(sqrt(z-1)*sqrt(z+1))
In [85]: e1.subs(z, I).n()
Out[85]: -0.707106781186548⋅ⅈ
In [86]: e2.subs(z, I).n()
Out[86]: -0.707106781186548⋅ⅈ
In [87]: e1.subs(z, -I).n()
Out[87]: -0.707106781186548⋅ⅈ
In [88]: e2.subs(z, -I).n()
Out[88]: 0.707106781186548⋅ⅈ At In [93]: e1 = sign(re(z))/sqrt(z**2 - 1)
In [94]: e2 = 1/(sqrt(z-1)*sqrt(z+1))
In [95]: e1.subs(z, 0.5).n()
Out[95]: -1.15470053837925⋅ⅈ
In [96]: e2.subs(z, 0.5).n()
Out[96]: -1.15470053837925⋅ⅈ
In [97]: e1.subs(z, -0.5).n()
Out[97]: 1.15470053837925⋅ⅈ
In [98]: e2.subs(z, -0.5).n()
Out[98]: -1.15470053837925⋅ⅈ At least for mpmath's numerical evaluation it seems that the new formula in this PR ( In [99]: x = -0.5
In [100]: h = 0.0001
In [101]: N((acosh(x+h) - acosh(x))/h)
Out[101]: -1.15466205349524⋅ⅈ
In [102]: x = I
In [103]: N((acosh(x+h) - acosh(x))/h)
Out[103]: 1.7677669020512e-5 - 0.707106780890414⋅ⅈ
In [104]: x = -I
In [105]: N((acosh(x+h) - acosh(x))/h)
Out[105]: 1.7677669020512e-5 + 0.707106780890414⋅ⅈ From a casual check this looks good but it would be good to do some serious consistency checking. Looks like the result for In [6]: acsch(z).diff(z)
Out[6]:
-1
────────────────
________
2 ╱ 1
z ⋅ ╱ 1 + ──
╱ 2
╲╱ z Maybe there should be some tests that randomly substitute values into different functions to check whether the numerical derivative agrees with the symbolic derivative at least under evaluation by mpmath. I expect that a bunch of bugs could be found like this one if all functions were tested. |
It would be good to have a test for the integral in the issue as well. |
it seems that the definition given in wikipedia for complex arguments will agree with the title. It has the proper branch cut (-oo, 1). |
d22969e
to
70abd70
Compare
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) before after ratio
[77f1d79c] [d0134b30]
<sympy-1.10.1^0>
+ 124±2ms 233±5ms 1.89 sum.TimeSum.time_doit
Full benchmark results can be found as artifacts in GitHub Actions |
Failed (wrong) tests are corrected in other PRs, and |
@@ -1102,7 +1102,8 @@ def test_derivs(): | |||
assert sech(x).diff(x) == -tanh(x)*sech(x) | |||
assert acoth(x).diff(x) == 1/(-x**2 + 1) | |||
assert asinh(x).diff(x) == 1/sqrt(x**2 + 1) | |||
assert acosh(x).diff(x) == 1/sqrt(x**2 - 1) | |||
assert acosh(x).diff(x) == 1/(sqrt(x - 1)*sqrt(x + 1)) | |||
assert acosh(x).diff(x) == acosh(x).rewrite(log).diff(x).simplify() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't use simplify
in test code. Instead a more targeted simplification function should be used e.g. in this case together
is sufficient.
References to other Issues or PRs
This justifies #23566
Wolfram Alpha result: https://www.wolframalpha.com/input?i=arccosh%28x%29+derivative
Brief description of what is fixed or changed
Other comments
Release Notes