Last active
August 18, 2021 21:11
-
-
Save jaems33/b90239912ea71f5f53841588cb373181 to your computer and use it in GitHub Desktop.
Catenary Equation in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
double catenary(const double x, const double a) { | |
return a * cosh(x / a); | |
} | |
double catenary_with_eulers(const double x, const double a) { | |
return (a / 2.0) * (exp(x / a) + exp(-x / a)); | |
} | |
int main(void) { | |
const double x = -2.0; | |
const double a = 2.0; | |
const double y1 = catenary(x, a); | |
const double y2 = catenary_with_eulers(x, a); | |
printf("Hyperbolic cosine of %lf (in radians) = %lf\n", x, y1); | |
printf("Hyperbolic cosine of %lf (in radians) = %lf\n", x, y2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment