{"action":"opened","issue":{"url":"https://api.github.com/repos/tgdwyer/WebCola/issues/73","labels_url":"https://api.github.com/repos/tgdwyer/WebCola/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/tgdwyer/WebCola/issues/73/comments","events_url":"https://api.github.com/repos/tgdwyer/WebCola/issues/73/events","html_url":"https://github.com/tgdwyer/WebCola/issues/73","id":55808226,"number":73,"title":"computeDerivatives stuck in an infinite loop ","user":{"login":"qinfchen","id":8294715,"avatar_url":"https://avatars.githubusercontent.com/u/8294715?v=3","gravatar_id":"","url":"https://api.github.com/users/qinfchen","html_url":"https://github.com/qinfchen","followers_url":"https://api.github.com/users/qinfchen/followers","following_url":"https://api.github.com/users/qinfchen/following{/other_user}","gists_url":"https://api.github.com/users/qinfchen/gists{/gist_id}","starred_url":"https://api.github.com/users/qinfchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qinfchen/subscriptions","organizations_url":"https://api.github.com/users/qinfchen/orgs","repos_url":"https://api.github.com/users/qinfchen/repos","events_url":"https://api.github.com/users/qinfchen/events{/privacy}","received_events_url":"https://api.github.com/users/qinfchen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-28T20:07:50Z","updated_at":"2015-01-28T20:07:50Z","closed_at":null,"body":"I noticed that computeDerivatives in descent.ts would stuck in an infinite loop if the parameter x contains huge numbers:\r\n```javacript\r\nwhile (true) {\r\n    var sd2 = 0;\r\n    for (i = 0; i < this.k; ++i) {\r\n        var dx = d[i] = x[i][u] - x[i][v];\r\n        sd2 += d2[i] = dx * dx;\r\n    }\r\n    if (sd2 > 1e-9)\r\n        break;\r\n    var rd = this.offsetDir();\r\n    for (i = 0; i < this.k; ++i)\r\n        x[i][v] += rd[i];\r\n    }\r\n```\r\n\r\n`dx` would be zero even though `x[i][u]` and `x[i][v]` aren't exactly same. This is because numbers in javascript are floating point and javascript rounds them to nearest number they can represent as 64 bit float. "}}