By downloading this code you agree to the
Source Code Use License (PDF). |
{version = 1.05; (* of coscurve.p 2000 Oct 31}
(* begin module describe.coscurve *)
(*
name
coscurve: compute the length of the cosine curve
synopsis
coscurve(coscurvep: in, output: out)
files
coscurvep: parameters to control the program. The file must contain the
following parameters, one per line:
parameterversion: The version number of the program. This allows the
user to be warned if an old parameter file is used.
second line: intervals (integer): number of intervals to use
third line: wid (integer): width of the output real numbers (in characters)
fourth line: printcontrol: the first character determines how or
whether to print the values during the summation.
P: print x, y, dy, L, L/2pi at each step
p: print L/2pi at each step
m: print L/2pi at each successively larger power of 10
-: no printing (fastest compute)
output: messages to the user
description
The cosine wave on a sequence logo can have dashes. These are implemented
in PostScript using the PostScript dash function. To make the dashes line
up with the wavelength the length of the curve must be known. So the
problem is to compute length of y = cos(x) from 0 to 2 pi. Setting ds =
sqrt(dx^2 +dy^2) (Thomas, pages 203-204) we find that the total length is
L = integral sqrt(1 + sin^2(x)) dx. This is not solvable in terms of
elementary functions (Thomas, page 308) and so must be determined
numerically. That is the purpose of this program.
Rather than integrate the function, it is easier just to sum the ds for
the interval 0 to 2 pi. The value L/(2pi) is reported so that this need
not be computed in the final program, which uses the constant.
The user may then multiply L/(2pi) by the amplitude and wavelength of a
given cosine or sine wave to get its contour length.
examples
for cocurvep being:
1.03 version of coscurve that this parameter file is designed for.
100000000 number of intervals to use
20 width of output real numbers in characters
m 2 printing: P: all, p: just L/2pi, m: multiples of k, - no printing.
the output is:
coscurve 1.05
pi = 3.14159265358979312
intervals = 100000000
2, L/(2pi) = 1.18544706105728359
4, L/(2pi) = 1.18544706105728359
8, L/(2pi) = 1.20642353304458783
16, L/(2pi) = 1.21356557113189623
32, L/(2pi) = 1.21539466952667086
64, L/(2pi) = 1.21585359980789032
128, L/(2pi) = 1.21596843563495249
256, L/(2pi) = 1.21599715104708350
512, L/(2pi) = 1.21600433030360899
1024, L/(2pi) = 1.21600612514295325
2048, L/(2pi) = 1.21600657385437816
4096, L/(2pi) = 1.21600668603233197
8192, L/(2pi) = 1.21600671407678718
16384, L/(2pi) = 1.21600672108796770
32768, L/(2pi) = 1.21600672284060907
65536, L/(2pi) = 1.21600672327877302
131072, L/(2pi) = 1.21600672338823634
262144, L/(2pi) = 1.21600672341558114
524288, L/(2pi) = 1.21600672342506755
1048576, L/(2pi) = 1.21600672342277272
2097152, L/(2pi) = 1.21600672342234084
4194304, L/(2pi) = 1.21600672341971094
8388608, L/(2pi) = 1.21600672346093108
16777216, L/(2pi) = 1.21600672339648463
33554432, L/(2pi) = 1.21600672338265259
67108864, L/(2pi) = 1.21600672333825899
L = 7.64039557751054144
L/(2pi) = 1.21600672333825899
==========
documentation
George B. Thomas, Jr.
Calculus and Analytic Genometry, 4th Ed
Addison-Wesley Publishing Co.
Reading, MA. 1968.
see also
Parameter file: coscurvep
The program that uses this number: makelogo.p
author
Thomas Dana Schneider
bugs
technical notes
*)
(* end module describe.coscurve *)
{This manual page was created by makman 1.45}
{created by htmlink 1.62}