// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Newton iteration with a convergence check // Not compiled or tested in-world // Setup: Place in a spare owned prim. Set VALUE positive. Touch to run; output is private to the owner. // Stop / restore: Disable/remove. No scene changes or external calls. // Notes: Stops on a relative change threshold or after thirty steps; llSqrt is printed as a reference, not used in the iteration. // License: see LICENSE in this distribution. // Original Incoprea. MIT. float VALUE=37.0; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(VALUE<=0.0) { llOwnerSay("Positive value required."); return; } float guess=VALUE; if(guess<1.0)guess=1.0; integer i; integer done; for(i=0;i<30&&!done;++i) { float next=0.5*(guess+VALUE/guess); done=(llFabs(next-guess)<0.000001*(1.0+llFabs(next))); guess=next; } llOwnerSay("Root="+(string)guess+" reference="+(string)llSqrt(VALUE)+" iterations="+(string)i); } }