Click here to Skip to main content
15,915,600 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Seeking A Solution Pin
Dr.Walt Fair, PE22-Jun-10 4:44
professionalDr.Walt Fair, PE22-Jun-10 4:44 
GeneralRe: Seeking A Solution Pin
Roger Wright22-Jun-10 5:10
professionalRoger Wright22-Jun-10 5:10 
GeneralRe: Seeking A Solution Pin
Luc Pattyn22-Jun-10 6:31
sitebuilderLuc Pattyn22-Jun-10 6:31 
GeneralRe: Seeking A Solution Pin
Dr.Walt Fair, PE22-Jun-10 7:24
professionalDr.Walt Fair, PE22-Jun-10 7:24 
GeneralRe: Seeking A Solution Pin
Roger Wright22-Jun-10 8:23
professionalRoger Wright22-Jun-10 8:23 
GeneralRe: Seeking A Solution Pin
Dr.Walt Fair, PE22-Jun-10 8:54
professionalDr.Walt Fair, PE22-Jun-10 8:54 
GeneralRe: Seeking A Solution Pin
Luc Pattyn22-Jun-10 9:42
sitebuilderLuc Pattyn22-Jun-10 9:42 
AnswerRe: Seeking A Solution Pin
harold aptroot22-Jun-10 6:17
harold aptroot22-Jun-10 6:17 
I made this, but it's not an analytical answer..
C#
static double Solve(double y)
{
    double x = y;
    double error = double.MaxValue;
    double prevError = double.PositiveInfinity;

    while (error != 0 && Math.Abs(prevError) > Math.Abs(error))
    {
        x -= (x - Math.Sin(x) - y) / (1 - Math.Cos(x));
        prevError = error;
        error = y - (x - Math.Sin(x));
    }

    return x;
}

It doesn't work for zero, and gives infinity for y < 0.00000001054, but otherwise it seems alright.
The input is supposed to be your value for 4R/D and the output will approximate Φ.
I can't guarantee that it will always terminate, but it did for every value I tested (which included negative numbers, and insanely big numbers, and very small numbers)
GeneralRe: Seeking A Solution Pin
Luc Pattyn22-Jun-10 6:29
sitebuilderLuc Pattyn22-Jun-10 6:29 
GeneralRe: Seeking A Solution Pin
harold aptroot22-Jun-10 6:39
harold aptroot22-Jun-10 6:39 
GeneralRe: Seeking A Solution Pin
Roger Wright22-Jun-10 17:24
professionalRoger Wright22-Jun-10 17:24 
GeneralRe: Seeking A Solution Pin
harold aptroot22-Jun-10 23:34
harold aptroot22-Jun-10 23:34 
GeneralRe: Seeking A Solution Pin
Luc Pattyn23-Jun-10 2:43
sitebuilderLuc Pattyn23-Jun-10 2:43 
AnswerRe: Seeking A Solution Pin
cp987623-Jun-10 14:21
cp987623-Jun-10 14:21 
GeneralRe: Seeking A Solution [modified] Pin
Roger Wright23-Jun-10 20:01
professionalRoger Wright23-Jun-10 20:01 
GeneralRe: Seeking A Solution Pin
cp987623-Jun-10 21:28
cp987623-Jun-10 21:28 
GeneralRe: Seeking A Solution Pin
harold aptroot23-Jun-10 21:48
harold aptroot23-Jun-10 21:48 
GeneralRe: Seeking A Solution Pin
cp987624-Jun-10 1:08
cp987624-Jun-10 1:08 
GeneralRe: Seeking A Solution Pin
cp987624-Jun-10 1:22
cp987624-Jun-10 1:22 
GeneralRe: Seeking A Solution Pin
harold aptroot24-Jun-10 1:50
harold aptroot24-Jun-10 1:50 
GeneralRe: Seeking A Solution Pin
cp987624-Jun-10 3:26
cp987624-Jun-10 3:26 
GeneralRe: Seeking A Solution Pin
Roger Wright26-Jun-10 19:54
professionalRoger Wright26-Jun-10 19:54 
GeneralRe: Seeking A Solution Pin
cp987627-Jun-10 0:57
cp987627-Jun-10 0:57 
GeneralRe: Seeking A Solution Pin
Roger Wright27-Jun-10 3:56
professionalRoger Wright27-Jun-10 3:56 
GeneralRe: Seeking A Solution Pin
cp987627-Jun-10 19:33
cp987627-Jun-10 19:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.