// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Find a minimum in a bounded interval // Not compiled or tested in-world // Setup: Place in a spare owned prim. Edit function f and its bracket together. Touch to run; output is private to the owner. // Stop / restore: Disable/remove. No scene changes or external calls. // Notes: Requires a unimodal function on the bracket; a fixed32-step cap limits work. Does not guarantee a global minimum on arbitrary functions. // License: see LICENSE in this distribution. // Original Incoprea. MIT. float f(float x) { return (x-2.3)*(x-2.3)+1.0; } default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; float a=-2.0; float b=6.0; float ratio=0.618033989; float c=b-ratio*(b-a); float d=a+ratio*(b-a); float fc=f(c); float fd=f(d); integer i; for(i=0;i<32;++i) { if(fc