Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DWORD ApproximateExampleThree(){
- double stepSize = 0.0;
- double tResult = 0.0;
- double mResult = 10000.0;
- double iterator = 10000.0;
- double preciseValue = log(pow(10.0, -6))/(-1.0/500.0);
- fflush(stdin);
- _tprintf(_T("Approximating equation [m' = -(m/V)*v], where V = 1000 m^3, v = 2 m^3/s.\n"));
- _tprintf(_T("Please enter size of the step [#.#]: "));
- _tscanf(_T("%lf"), &stepSize);
- if(stepSize <= 0){
- _tprintf(_T("Size of the step can't be zero or negative! Aborting... \n"));
- return ERROR_INVALID_PARAMETER;
- }
- for(iterator; iterator > 1.0/100.0; iterator -= stepSize){
- tResult = tResult + stepSize;
- mResult = mResult + stepSize*(-mResult/500.0);
- }
- _tprintf(_T("\nPrecise result is: %.10f seconds.\n"), preciseValue);
- _tprintf(_T("Approximate result is: %.10f seconds\n"), mResult);
- _tprintf(_T("Approximation error is: %.2f%%"), (fabs(preciseValue - mResult)/fabs(preciseValue))*100);
- return ERROR_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement