// Aufgabe 23-2a.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "std-rene-schwarz.h"
#include "math.h"


int _tmain(int argc, _TCHAR* argv[])
{
	cout << rsheader << endl;

	float a, b, p, q, r, x, nst, puffer;


	cout << "Newtonsches Interationsverfahren\n================================\nAufgabe 23-1a\n\n" << endl;


	cout << "f(x) = p*x + q*sin(x) + r\n\n" << endl;
	cout << "Bitte geben Sie nun die folgenden Parameter ein:" << endl;
	cout << "p: ";
	scanf_s("%f", &p);
	cout << "q: ";
	scanf_s("%f", &q);
	cout << "r: ";
	scanf_s("%f", &r);
	cout << "\nF" << ue << "r das Newtonsche Interationsverfahren sind verschiedene Vorgaben notwendig." << endl;
	cout << "Intervallgrenze a: ";
	scanf_s("%f", &a);
	cout << "Intervallgrenze b: ";
	scanf_s("%f", &b);
	cout << "Startwert x: ";
	scanf_s("%f", &x);

	while( !((x > a && x < b) || (x > b && x < a)) )
	{
		cout << "\nIhr Startwert x liegt nicht im angegebenen Intervall." << endl;
		cout << "Startwert x: ";
		scanf_s("%f", &x);
	}

	nst = x;

	if(a < b)
	{
		puffer = a - 1;
	}
	else
	{
		puffer = b - 1;
	}

	while( (long int)(puffer*100000) != (long int)(nst*100000) )
	{
		puffer = nst;
		nst = nst - ((p*nst + q*sin(nst) + r) / (p + q*cos(nst)));
		cout << "Iterationsschritt: x0 = " << (float)nst << endl;
	}

	cout << "Die Nullstelle liegt ann" << ae << "hernd bei x0 = " << (float)nst << endl;

	return 0;
}


