-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Final definite-integral
interface wrapping up all integral work!! (integrals #10)
#129
Conversation
;; more general method. | ||
|
||
(def ^:private quadrature-methods | ||
{:open {:method :adaptive-bulirsch-stoer |
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've dominated scipy :)
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.
That we have. I really think you have covered some uncharted territory. As an overview, it's clear that GJS wanted strong integrators capable of producing plots of function values with integrals on the RHS, looked at the state of the art, realized that the QUADPACK people had lost the plot, and decided to return to first principles with the Memo. But his approach was depth-first, since numerical analysis is not the focus of his work. This is different, these methods are quite a bit better than just cranking down
;; | ||
;; Here we are! The one function you need care about if you're interested in | ||
;; definite integrals. Learn to use this, and then dig in to the details of | ||
;; individual methods if you run inton trouble or want to learn more. Enjoy! |
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.
inton
→ into
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.
Thanks!
Codecov Report
@@ Coverage Diff @@
## sritchie/integral_9 #129 +/- ##
======================================================
Coverage ? 85.95%
======================================================
Files ? 71
Lines ? 6080
Branches ? 297
======================================================
Hits ? 5226
Misses ? 557
Partials ? 297 Continue to review full report at Codecov.
|
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.
Bravo! 🥇
;; more general method. | ||
|
||
(def ^:private quadrature-methods | ||
{:open {:method :adaptive-bulirsch-stoer |
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.
That we have. I really think you have covered some uncharted territory. As an overview, it's clear that GJS wanted strong integrators capable of producing plots of function values with integrals on the RHS, looked at the state of the art, realized that the QUADPACK people had lost the plot, and decided to return to first principles with the Memo. But his approach was depth-first, since numerical analysis is not the focus of his work. This is different, these methods are quite a bit better than just cranking down
(is (near 2.0532 (f 0.60))) | ||
(is (near 2.08001 (f 0.75))) | ||
(is (near 2.11368 (f 0.9)))))) | ||
|
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.
Are we getting more significance in the result of this just using straight-up integrate? This one is improper on the left, so by saying that in the options we should get much better results without asking for 1e-9.
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.
It's improper on the right, yeah? 0
gives us a denominator of 1 / sqrt(2g (1 - cos(a))
, while a
gives us a pole.
It looks like we can tighten up the near
test and remove the options map, and get a passing test:
(testing "harder"
(let [near (v/within 1e-5)
g 9.8
integrand (fn [theta0]
(fn [theta]
(/ (Math/sqrt
(* 2 g (- (Math/cos theta)
(Math/cos theta0)))))))
L (fn [a]
(let [f (integrand a)]
(* 4 (q/definite-integral f 0 a {:method :closed-open}))))]
(is (near 2.00992 (L 0.15)))
(is (near 2.01844 (L 0.30)))
(is (near 2.03279 (L 0.45)))
(is (near 2.0532 (L 0.60)))
(is (near 2.08001 (L 0.75)))
(is (near 2.11368 (L 0.9)))))
I need to stare at this more, since I've lost touch with the physics and can't remember what system we're describing :)
It's done!! This PR:
definite-integral
function and interface@littleredcomputer, I realize I removed your adaptive simpson's implementation, which is great - wdyt, should we move that over to
simpson.cljc
, and make it its own integrator?IT'S DONE!