#!/usr/bin/perl -w

use Math::Trig;
use GD;
use constant left  => 50;
use constant right => 150;
use constant b     => 10;

sub catenary { return b * cosh(($_[0] - right + left)/b) }

$image = new GD::Image(200, 200);
$image->colorAllocate(255, 255, 255);
$black = $image->colorAllocate(0,0,0);

for ($x = left; $x <= right; $x += 0.01) {
    $image->setPixel($x, 200-catenary($x), $black);
}

print $image->gif;
