/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* solver.c
* Copyright (C) 2016 drdev
*
* solver is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* solver is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*/
/*
In this example, we seek the intersection of csc(x) and coth(csc(x)),
which exists at about 0.98551473786
*/
#include
#include
double ang_rad;
double eqn1,eqn2;
double increment;
int loops;
double csc(double ang)
{
return 1/sin(ang);
}
double coth(double ang)
{
return (1+exp(-2*ang))/(1-exp(-2*ang));
}
int main()
{
ang_rad = 0.90;
increment = 0.005;
for (loops = 0; loops<6;loops++)
{
do
{
eqn1 = csc(ang_rad);
eqn2 = coth(eqn1);
printf("%1.16g\t%1.16g\t%1.16g\n", ang_rad,eqn1,eqn2);
ang_rad = ang_rad+increment;
}
while (eqn1>eqn2);
increment = increment/10;
do
{
eqn1 = csc(ang_rad);
eqn2 = coth(eqn1);
printf("%1.16g\t%1.16g\t%1.16g\n", ang_rad,eqn1,eqn2);
ang_rad = ang_rad-increment;
}
while (eqn1