Giter Club home page Giter Club logo

calculuswithjulia.github.io's Introduction

calculuswithjulia.github.io's People

Contributors

calculuswithjulia avatar edjroot avatar jverzani avatar mth229 avatar smonsays avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

calculuswithjulia.github.io's Issues

Exponentiation is not one operation to compute

https://calculuswithjulia.github.io/precalc/polynomial.html#Factoringpolynomials

For example, the polynomial (x−1)1000 can be compactly represented using the factored form, but would require 1001 coefficients to store in expanded form. (As well, due to floating point differences, the two would evaluate quite differently as one would require over a 1000 operations to compute, the other just two.)

I don't think exponentiation is one operation, except where the base is a power of two. If the implementation does use the x86 floating point exponentiation instruction (which I don't think Julia does), then it's worth noting that that operation takes a lot longer than a single multiply and introduces rounding error (maybe more than the multiplies), so this isn't quite right.

Just for fun:

using BenchmarkTools

f(a, b) = a^b

# Exponentiate by squaring.
# Other algorithms are available
g(a, b) = let acc = a
    for _ in 1:b-1
        acc *= a
    end
    acc
end

@assert f(10.0, 50) == g(10.0, 50)
@assert f(.9, 100) == g(.9, 100)

# Same speed
@benchmark f(10.0, 50)
@benchmark g(10.0, 50)

# f is 50x faster, but that's because there's a better algorithm available for these smaller numbers that llvm is picking for us, I think.
@benchmark f(.9, 100)
@benchmark g(.9, 100)

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.