3 ms·
How's that implemented? Newton's method like in the OP? I.e. if there's at least one solution there's an okay chance to find at most one solution?
by H8crilA 7y ago
How's that implemented? Newton's method like in the OP? I.e. if there's at least one solution there's an okay chance to find at most one solution?
- xelxebar 7y agoEssentially, yes. > (^~^:_1) 5 First, let me break this down, in the interest of sharing the joys of J. The thing in parenthesis is our inverse operation of x^x; we then evaluate that at 5. The first ^ is exponentiation and the following ~ makes binary operators into unary ones by evaluating on the diagonal. In other words it turns f(x,y) into f(x) = f(x,x), which for x^y corresponds to x^x. Next we have the ^: modifier. This is function iteration, i.e. exponentiation over function composition. The function is on the left (here ^~) and the count on the right (here _1). So f ^: 2 means f(f(x)). In fact, this function exponentiation is extended to negative integers as well! In J, negative numbers are prefixed with _ (underscore), and f^:_1 actually gives us the inverse of f (if it exists)! Anyway, we can see inspect the definition for an operation's inverse using the b. verb. From the jconsole: ^~ b. _1 3 : '(- -&b@(*^.) % >:@^.)^:_ ]1>.b=.^.y'"0 :.(^~) The part we are interested in is in single quotes. Pulling this one apart would involve introducing the various operator combinators in J, so suffice it to say that the ^:_ part numerically approximates a fixed point of the part in parenthesis, which essentially is a straightforward transcription of the recursive relation in Newton's method.