Giter Club home page Giter Club logo

cycloidseries's Introduction

Cycloid Series

This is a SageMath script that graphs a cycloid using a Fourier Series representation:

Raw:

Here is the raw text, for those not working in a Jupyter notebook:

# This is a really neat Fourier Series that is equivalent to a cycloid. This is fascinating 
#  due to the way the change of variables happens for the coefficients in the series. That is, 
#  a cycloid has no implicitization, only a parametric representation, so a change of 
#  variables must happen within the Fourier coefficients to obtain this series.
#
# Author: Luke V.

# resolution of sum
r = 100

x = var('x')
t = var('t')

# cycloid and first derivative of x
fx = t - sin(t)
fy = 1 - cos(t)
diffx = diff(fx, t)

# find the root so we can chage the bounds of our integrals
lim = find_root(fx == 2 * pi, 0, 2 * pi)

# atrocious fourier series
func = 1 / (2 * pi) * (1 / 2 * (numerical_integral(fy * diffx, -lim, lim)[0])
                        + sum(
                        (numerical_integral(fy * diffx * cos(n * pi * (fx) / lim), -lim, lim)[0]) * cos(n * x / 2)
                        for n in xrange(2, r, 2))) # every odd term is zero, skip calculating them

# plot the series and the first arch of the cycloid
p = plot(func, (x, -4 * pi, 4 * pi), aspect_ratio=1, color='blue')
p1 = parametric_plot((fx, fy), (t, 0, 2 * pi), aspect_ratio=1, color='red')

# show the series with the first arch of the cycloid drawn on top
show(p + p1)

cycloidseries's People

Contributors

wulfsta avatar

Watchers

 avatar  avatar

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.