Giter Club home page Giter Club logo

Comments (2)

lbenet avatar lbenet commented on August 11, 2024

Thanks for reaching out and for your question! I'm not sure the following answers the question, so I'll try to guide you through the code, and indicate where you can modify something.

sqrt(::Taylor1) executes this line. The first code block checks where the first non-zero coefficient of the Taylor1 polynomial is located; that is actually where the error is thrown, since for t=Taylor1(5) the first non-zero coefficient in this case is odd. The reason to distinguish odd and even first non-zero coefficients is, essentially, to be able to factor an expression of the form $\sqrt{t^{2n}* p(t)} = t^n*\sqrt{p(t)}$, with $p(t)$ a polynomial with non-zero 0-th order coefficient.

The next code block computes order by order the Taylor expansion. It uses sqrt! to update (modify in place) the Taylor coefficient of order k of c, which is the returned result. sqrt! is coded here, and you can check the docstrings here or in the REPL (? TaylorSeries.sqrt!). The function essentially implements the relevant formula (which does not appear properly displayed as it should in the documentation).

Let me point out that sqrt! throws no error, that sqrt(::Taylor1) computes the 0-th order coefficient separatelly, and that the rest of the coefficients are computed using sqrt!. So, if you want to code your own mysqrt, you should perhaps compute the Taylor expansion using sqrt! directly, including the first non-zero coefficient. Be aware that Infs and NaNs may propagate in the series, because the computation is recursive. This means that mysqrt(t) may return something like Inf t - Inf t² + Inf t³ - Inf t⁴ + Inf t⁵ + 𝒪(t⁶).

I hope this is useful for your application.

from taylorseries.jl.

lbenet avatar lbenet commented on August 11, 2024

Closing. Feel free to reopen this issue if you want further explanations..

from taylorseries.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.