File:Collatz Cobweb.svg

Original file(SVG file, nominally 422 × 421 pixels, file size: 26 KB)

Commons-logo.svg This is a file from the Wikimedia Commons. The description on its description page there is shown below.
Commons is a freely licensed media file repository. You can help.

Summary

Description
English: Cobweb plot of , an extension of the Collatz map to the real line, studied by Marc Chamberland. The orbit of the starting point is shown in red, with values .
Date
Source Own work
Author Hugo Spinelli
SVG development
InfoField
W3C grn 
The SVG code is valid.
Inkscape-yes 
This vector image was created with Inkscape.
Source code
InfoField
Try it here (permalink). Cleaned up with Inkscape afterwards.
SageMath code
var('x')
f = (x/2)*cos(pi*x/2)^2 + ((3*x + 1)/2)*sin(pi*x/2)^2
f_latex = r'$\frac{x}{2}\cdot\cos^2\left(\frac{\pi x}{2}\right) \,+\, \frac{3x + 1}{2}\cdot\sin^2\left(\frac{\pi x}{2}\right)$'

def cobweb(f, x, xmin, xmax, max_iter=100, f_latex=None):
    p = plot(f, (xmin, xmax), ymin=xmin, ymax=xmax, aspect_ratio=1, legend_label=f_latex)
    p += plot(lambda x: x, xmin=xmin, xmax=xmax, color='gray')
    path = [(x, 0)]
    for k in range(max_iter):
        y = f(x=x)
        path.append((x, y))
        x = y
        path.append((x, x))
        if (x, x) in path[:-1]:
            break
    p += line(path, rgbcolor=(1, 0, 0))
    return p

x0 = 10
xmin, xmax = 0, 12
p = cobweb(f, x=x0, xmin=xmin, xmax=xmax, f_latex=f_latex)
config = dict(
    aspect_ratio=1, legend_font_size=13.5, legend_handlelength=1.5, legend_borderpad=0.3, legend_loc='upper left',
    ticks=[[xmin..xmax], [xmin..xmax]], tick_formatter='latex', ticks_integer=True,
    gridlines=True, gridlinesstyle={'linestyle': ':'}
)
show(p, **config)
p.save('Collatz_Cobweb.svg', **config)

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Captions

Cobweb plot of Chamberland's extension of the Collatz map, with the orbit of the starting point x = 10.

Items portrayed in this file

depicts

5 October 2023

image/svg+xml

851e6b2d103653e07f4c8714fcb238e86bbb5b19

26,657 byte

421 pixel

422 pixel

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeDimensionsUserComment
current14:39, 5 October 2023422 × 421 (26 KB)Hugo SpinelliUploaded own work with UploadWizard

The following page uses this file:

Metadata