5 kyu

"Dual Numbers" and "Automatic" (nth) Derivatives

Description
Loading description...
Mathematics
Algebra
Fundamentals
Tutorials
  • Please sign in or sign up to leave a comment.
  • algirdasN Avatar

    Amazing kata, thank you. I've learned a lot while trying to solve it :)

  • 4500zenja1 Avatar

    This kata is pretty good, although I spent about a week to find the derivative without errors. I think all this time I was thinking "inside of box" or smth else, but the solution was pretty nice even without specific formulas (except for lambdas).

    I wish this kata will go out of beta, gl :)

    • Quaternions Avatar

      Thanks ! :D I -obviously- hope too^^ (I thought it was "dead"; but I'm happy to see people are still testing/commenting it ==> Thanks for "bringing back some hope I had lost" :p )

  • Kacarott Avatar

    The description should be better formatted. In particular, titles should use 'normal' formatting (left aligned), and the font size should be more consistent. (You use the small font very often, and even then it is different levels of 'smallness', and sometimes random large font in the middle of sentences, for example function deriv(f,n=1).

    I also think the initial solution should be better formatted, with comments on their own lines directly above function declarations (rather than on the same lines/ inside the functions?)

    • Quaternions Avatar

      Thanks for the feedback :) Currently, it's obviously still "far from perfect" (sorry for the euphemism), but I aleady applied some changes (titles etc; note that despite using Codewars formatting, I was still "obliged" to add a "br/" before each title, otherwise, it tended to "stick to the previous paragraph", in particular after Math blocks, which REALLY looked awful... )

      Yeah the function deriv(f,n=1) and R_e class in huge was a bad idea, sorry; it was supposed to play the role of a kind of "pseudo-title"... But very bad Idea I admit, so I removed that font...

      As for the initial solution, I made some mild changes too: however, instead of putting the comments "above the function declarations" as you suggested, I rather put "everything inside" (i.e. after the function declaration and before the "pass" keyword: I personally find it "more natural" than "above the functions" [but if people really disagree with my opinion, I may change it])

      As for the "tiny size comments"... Yeah, as I feared, I guess I'm gonna be forced t change that (?) :'(... They were comments that felt like: "I guess for most (but maybe not all) people, it probably won't be worth reading... BUT I would feel really REALLY bad not to mention it :'("

    • Kacarott Avatar

      That looks already a lot better. It could still probably be improved but I think its no longer "issue" worthy. Nice kata btw :)

      Issue marked resolved by Kacarott 4 years ago
    • Quaternions Avatar

      Thank you very much! :)

  • Kacarott Avatar

    This comment has been hidden.

    • Quaternions Avatar

      Oh I did make research to find if there was already a similar Kata and had found nothing (only tons and tons of Katas about differentiation that "manipulates strings"...); but it's true I didn't think about looking with other languages, such as Haskell (I know 0 about the latter; I just remembered I had read it was "not object-oriented" so I'm a bit surprised that such a Kata would precisely happen to be in that language...). But as you said, it has "more 'educational' approach", calculates the "nth" derivative raher than only the first one (and also designed to be very easy to generalize further), and completely different languages... [EDIT: and also note that my Kata focuses quite a lot on Dual Numbers and there are very specific instructions about the Class R_e; and most tests concern that specific class... While in the Haskell Kata, the focus is only on "calculating the derivative"; Dual Numbers are not explicitly mentioned (although they are probably the "only realistic way" to achieve the task), and -a fortiori- not tested] (I hope it'll still be accepted, as it would have been quite frustrating to have written all of that just to get it "rejected" :'( ...)

    • dfhwze Avatar

      In case it's a duplicate, you might want to increase its difficulty level (even more) -> you already hinted in the description more generalized/complex use cases exist.

    • Quaternions Avatar

      @dfhwze Thanks for the suggestion :) (But I do believe/hope it's not a "duplicate" [while on the other hand, despite being new here, I've already seen many ("Real") "duplicates" (sometimes by the same author!) that somehow got "approved" :/ ...I don't like being "that guy", but "I could even show examples"...];

      If it should happen to be the case, then your idea would indeed be the "Best option"; but it would be a pitty, as my goal with this Kata was to take the approach: "Implement a class about an Abstract Mathematical Structure; then add one line of code to turn it into a useful algorithm"... So of course, I could add "quaternions", or "symbolic expressions" or simply ask to "include trigonometric and/or hyperbolic (and maybe elliptic) functions" [that could actually be the simplest option], but I feel it might "spoil" the Kata's purpose a little bit :/ ==> But that would indeed be the best option in case it ends up being considered as a "duplicate" [I really hope it won't; besides I find my Kata globally looks "quite different" from that Haskell Kata; while on the other hand, I think there are many katas about "derivatives" using "string manipulation" that really look like eachother... In my opinion]...)