Starting interactive Python…
import%20sys%20as%20_browser_sys%0Aif%20_browser_sys.platform%20%3D%3D%20'emscripten'%3A%0A%20%20%20%20import%20re%20as%20_browser_re%0A%20%20%20%20import%20micropip%20as%20_browser_pip%0A%20%20%20%20for%20_browser_attempt%20in%20range(4)%3A%0A%20%20%20%20%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20await%20_browser_pip.install(%5B'wigglystuff%3D%3D0.5.32'%2C%20'plotly%3D%3D7.0.0'%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20except%20ValueError%20as%20_browser_error%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20_browser_conflict%20%3D%20_browser_re.search(r'but%20(%5CS%2B)%3D%3D%5CS%2B%20is%20already%20installed'%2C%20str(_browser_error))%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20_browser_conflict%20is%20None%20or%20_browser_attempt%20%3D%3D%203%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20raise%0A%20%20%20%20%20%20%20%20%20%20%20%20_browser_pip.uninstall(_browser_conflict%5B1%5D)%0Aimport%20json%20as%20_obsidian_json%0A_obsidian_namespace%20%3D%20%7B%7D%0Aexec('%22%22%22Obsidian%20extensions%20for%20the%20pinned%20marimo%20Markdown%20parser%20(also%20runs%20in%20Pyodide).%22%22%22%5Cnimport%20html%5Cnimport%20posixpath%5Cnimport%20re%5Cnimport%20threading%5Cnimport%20unicodedata%5Cnfrom%20urllib.parse%20import%20unquote%5Cnfrom%20xml.etree%20import%20ElementTree%20as%20ET%5Cn%5Cnfrom%20markdown%20import%20Extension%2C%20Markdown%5Cnfrom%20markdown.inlinepatterns%20import%20InlineProcessor%5Cnfrom%20markdown.preprocessors%20import%20Preprocessor%5Cnfrom%20markdown.treeprocessors%20import%20Treeprocessor%5Cnfrom%20markdown.util%20import%20AtomicString%5Cn%5Cn%5Cndef%20file_key(value)%3A%5Cn%20%20%20%20value%20%3D%20unquote(value).strip().strip(%22%2F%22)%5Cn%20%20%20%20value%20%3D%20re.sub(r%22%5C%5C.(%3F%3Amarimo(%3F%3A%5C%5C.py)%3F%7Cmd%7Chtml)%24%22%2C%20%22%22%2C%20value%2C%20flags%3Dre.I)%5Cn%20%20%20%20return%20re.sub(r%22%5C%5Cs%22%2C%20%22-%22%2C%20value).replace(%22%26%22%2C%20%22-and-%22).replace(%22%25%22%2C%20%22-percent%22).replace(%22%3F%22%2C%20%22%22).lower()%5Cn%5Cn%5Cndef%20heading_slug(value%2C%20separator%3D%22-%22)%3A%5Cn%20%20%20%20%23%20Preserve%20Unicode%20letters%2C%20numbers%2C%20marks%20and%20underscores%2C%20as%20Quartz%20does.%5Cn%20%20%20%20value%20%3D%20html.unescape(re.sub(r%22%3C%5B%5E%3E%5D*%3E%22%2C%20%22%22%2C%20value)).lower()%5Cn%20%20%20%20return%20%22%22.join(c%20for%20c%20in%20value%20if%20c%20in%20%22%20-_%22%20or%20unicodedata.category(c)%5B0%5D%20in%20%22LNM%22).replace(%22%20%22%2C%20%22-%22)%5Cn%5Cn%5Cndef%20load_index(url)%3A%5Cn%20%20%20%20%23%20The%20Vault%20index%20is%20one%20shared%2C%20HTTP-cached%20file%20instead%20of%20being%20inlined%5Cn%20%20%20%20%23%20into%20every%20notebook.%20Workers%20may%20use%20synchronous%20requests%3B%20the%20page%20loader%5Cn%20%20%20%20%23%20prefetches%20this%20URL%2C%20so%20the%20first%20link%20usually%20reads%20from%20cache.%5Cn%20%20%20%20import%20json%5Cn%20%20%20%20try%3A%5Cn%20%20%20%20%20%20%20%20from%20js%20import%20console%2C%20location%5Cn%20%20%20%20%20%20%20%20from%20pyodide.http%20import%20open_url%5Cn%20%20%20%20except%20ImportError%3A%5Cn%20%20%20%20%20%20%20%20%23%20Build-time%20execution%20reads%20the%20same%20index%20from%20a%20local%20file.%5Cn%20%20%20%20%20%20%20%20import%20os%5Cn%20%20%20%20%20%20%20%20path%20%3D%20os.environ.get(%22EWAN_MARIMO_LINK_INDEX%22)%5Cn%20%20%20%20%20%20%20%20if%20not%20path%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20return%20%5B%5D%5Cn%20%20%20%20%20%20%20%20with%20open(path)%20as%20file%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20return%20json.load(file).get(%22files%22%2C%20%5B%5D)%5Cn%20%20%20%20try%3A%5Cn%20%20%20%20%20%20%20%20return%20json.load(open_url(location.origin%20%2B%20url)).get(%22files%22%2C%20%5B%5D)%5Cn%20%20%20%20except%20Exception%20as%20error%3A%5Cn%20%20%20%20%20%20%20%20console.warn(f%22%5Bewan-marimo%5D%20link%20index%20unavailable%3A%20%7Berror%7D%22)%5Cn%20%20%20%20%20%20%20%20return%20%5B%5D%5Cn%5Cn%5Cnclass%20Resolver%3A%5Cn%20%20%20%20def%20__init__(self%2C%20context)%3A%5Cn%20%20%20%20%20%20%20%20self.current%20%3D%20context.get(%22currentSlug%22%2C%20%22index%22)%5Cn%20%20%20%20%20%20%20%20self.index%20%3D%20context.get(%22index%22)%5Cn%20%20%20%20%20%20%20%20self._entries%20%3D%20context.get(%22files%22)%5Cn%20%20%20%20%20%20%20%20self._keys%20%3D%20None%5Cn%5Cn%20%20%20%20%40property%5Cn%20%20%20%20def%20entries(self)%3A%5Cn%20%20%20%20%20%20%20%20if%20self._entries%20is%20None%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20self._entries%20%3D%20load_index(self.index)%20if%20self.index%20else%20%5B%5D%5Cn%20%20%20%20%20%20%20%20return%20self._entries%5Cn%5Cn%20%20%20%20%40property%5Cn%20%20%20%20def%20keys(self)%3A%5Cn%20%20%20%20%20%20%20%20if%20self._keys%20is%20None%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20self._keys%20%3D%20%7B%7D%5Cn%20%20%20%20%20%20%20%20%20%20%20%20for%20entry%20in%20self.entries%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20name%20in%20%5Bentry%5B%22path%22%5D%2C%20entry%5B%22slug%22%5D%2C%20*entry.get(%22aliases%22%2C%20%5B%5D)%5D%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20key%20%3D%20file_key(name)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self._keys.setdefault(key%2C%20%5B%5D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20entry%20not%20in%20self._keys%5Bkey%5D%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20self._keys%5Bkey%5D.append(entry)%5Cn%20%20%20%20%20%20%20%20return%20self._keys%5Cn%5Cn%20%20%20%20def%20resolve(self%2C%20target)%3A%5Cn%20%20%20%20%20%20%20%20target%20%3D%20unquote(target).strip()%5Cn%20%20%20%20%20%20%20%20if%20re.match(r%22%5E%5Ba-zA-Z%5D%5B%5C%5Cw%2B.-%5D*%3A%22%2C%20target)%20or%20target.startswith(%22%2F%2F%22)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20return%20target%2C%20None%5Cn%20%20%20%20%20%20%20%20name%2C%20sep%2C%20fragment%20%3D%20target.partition(%22%23%22)%5Cn%20%20%20%20%20%20%20%20key%20%3D%20file_key(name)%5Cn%20%20%20%20%20%20%20%20if%20not%20name%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20found%20%3D%20next((e%20for%20e%20in%20self.entries%20if%20e%5B%22slug%22%5D%20%3D%3D%20self.current)%2C%20None)%5Cn%20%20%20%20%20%20%20%20else%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20relative%20%3D%20file_key(posixpath.normpath(posixpath.join(posixpath.dirname(self.current)%2C%20key)))%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20name.startswith((%22.%2F%22%2C%20%22..%2F%22))%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20matches%20%3D%20self.keys.get(relative%2C%20%5B%5D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20else%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20matches%20%3D%20self.keys.get(key%2C%20%5B%5D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20name.startswith(%22%2F%22)%20and%20(not%20matches%20or%20%22%2F%22%20not%20in%20key)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20matches%20%3D%20%5B*matches%2C%20*%5Be%20for%20k%2C%20es%20in%20self.keys.items()%20if%20k.endswith(%22%2F%22%20%2B%20key)%20for%20e%20in%20es%5D%5D%5Cn%20%20%20%20%20%20%20%20%20%20%20%20matches%20%3D%20list(%7Be%5B%22slug%22%5D%3A%20e%20for%20e%20in%20matches%7D.values())%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%23%20A%20note%20next%20to%20this%20notebook%20wins%20an%20otherwise%20ambiguous%20basename.%5Cn%20%20%20%20%20%20%20%20%20%20%20%20nearby%20%3D%20%5Be%20for%20e%20in%20matches%20if%20posixpath.dirname(e%5B%22slug%22%5D)%20%3D%3D%20posixpath.dirname(self.current)%5D%5Cn%20%20%20%20%20%20%20%20%20%20%20%20found%20%3D%20matches%5B0%5D%20if%20len(matches)%20%3D%3D%201%20else%20nearby%5B0%5D%20if%20len(nearby)%20%3D%3D%201%20else%20None%5Cn%20%20%20%20%20%20%20%20if%20name%20and%20found%20is%20None%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20return%20None%2C%20None%5Cn%20%20%20%20%20%20%20%20slug%20%3D%20found%5B%22slug%22%5D%20if%20found%20else%20self.current%5Cn%20%20%20%20%20%20%20%20simple%20%3D%20re.sub(r%22(%3F%3A%5E%7C%2F)index%24%22%2C%20%22%2F%22%2C%20slug).rstrip(%22%2F%22)%5Cn%20%20%20%20%20%20%20%20root%20%3D%20%22..%2F%22%20*%20self.current.count(%22%2F%22)%20or%20%22.%2F%22%5Cn%20%20%20%20%20%20%20%20href%20%3D%20root%20%2B%20simple%5Cn%20%20%20%20%20%20%20%20if%20slug.endswith(%22%2Findex%22)%20or%20slug%20%3D%3D%20%22index%22%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20href%20%3D%20href.rstrip(%22%2F%22)%20%2B%20%22%2F%22%5Cn%20%20%20%20%20%20%20%20if%20not%20name%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20href%20%3D%20%22%22%5Cn%20%20%20%20%20%20%20%20if%20sep%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20name.lower().endswith(%22.pdf%22)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20anchor%20%3D%20fragment%5Cn%20%20%20%20%20%20%20%20%20%20%20%20elif%20fragment.startswith(%22%5E%22)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20anchor%20%3D%20fragment%5B1%3A%5D.lower()%5Cn%20%20%20%20%20%20%20%20%20%20%20%20else%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20anchor%20%3D%20(found%20or%20%7B%7D).get(%22headings%22%2C%20%7B%7D).get(fragment)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20anchor%20is%20None%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20anchor%20%3D%20heading_slug(fragment.split(%22%23%22)%5B-1%5D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20href%20%2B%3D%20%22%23%22%20%2B%20anchor%5Cn%20%20%20%20%20%20%20%20return%20href%2C%20found%5Cn%5Cn%5Cnclass%20WikiLinks(InlineProcessor)%3A%5Cn%20%20%20%20def%20__init__(self%2C%20md%2C%20resolver)%3A%5Cn%20%20%20%20%20%20%20%20super().__init__(r%22(%3F%3C!%5C%5C%5C%5C)(!%3F)%5C%5C%5B%5C%5C%5B(%5B%5E%5C%5C%5B%5C%5C%5D%5C%5Cn%5D%2B)%5C%5C%5D%5C%5C%5D%22%2C%20md)%5Cn%20%20%20%20%20%20%20%20self.resolver%20%3D%20resolver%5Cn%5Cn%20%20%20%20def%20handleMatch(self%2C%20match%2C%20data)%3A%5Cn%20%20%20%20%20%20%20%20raw%20%3D%20match.group(2).replace(r%22%5C%5C%7C%22%2C%20%22%7C%22)%5Cn%20%20%20%20%20%20%20%20target%2C%20divider%2C%20alias%20%3D%20raw.partition(%22%7C%22)%5Cn%20%20%20%20%20%20%20%20target%20%3D%20target.strip()%5Cn%20%20%20%20%20%20%20%20label%20%3D%20alias.strip()%20if%20divider%20else%20target.rsplit(%22%2F%22%2C%201)%5B-1%5D.removesuffix(%22.md%22)%5Cn%20%20%20%20%20%20%20%20href%2C%20entry%20%3D%20self.resolver.resolve(target)%5Cn%20%20%20%20%20%20%20%20if%20href%20is%20None%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20el%20%3D%20ET.Element(%22span%22%2C%20%7B%22class%22%3A%20%22internal-link%20is-unresolved%22%2C%20%22title%22%3A%20%22Unpublished%20or%20ambiguous%20note%3A%20%22%20%2B%20target%7D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20el.text%20%3D%20AtomicString(label)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20return%20el%2C%20match.start(0)%2C%20match.end(0)%5Cn%20%20%20%20%20%20%20%20if%20match.group(1)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20ext%20%3D%20posixpath.splitext(target.split(%22%23%22)%5B0%5D)%5B1%5D.lower()%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20ext%20in%20%7B%22.png%22%2C%20%22.jpg%22%2C%20%22.jpeg%22%2C%20%22.gif%22%2C%20%22.svg%22%2C%20%22.webp%22%2C%20%22.avif%22%2C%20%22.bmp%22%7D%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el%20%3D%20ET.Element(%22img%22%2C%20%7B%22src%22%3A%20href%2C%20%22alt%22%3A%20label%2C%20%22loading%22%3A%20%22lazy%22%7D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dimensions%20%3D%20re.fullmatch(r%22(%5C%5Cd%2B)(%3F%3Ax(%5C%5Cd%2B))%3F%22%2C%20alias.strip())%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20dimensions%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22width%22%2C%20dimensions%5B1%5D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20dimensions%5B2%5D%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22height%22%2C%20dimensions%5B2%5D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20elif%20ext%20in%20%7B%22.mp3%22%2C%20%22.wav%22%2C%20%22.ogg%22%2C%20%22.m4a%22%2C%20%22.flac%22%2C%20%22.mp4%22%2C%20%22.webm%22%2C%20%22.mov%22%7D%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tag%20%3D%20%22video%22%20if%20ext%20in%20%7B%22.mp4%22%2C%20%22.webm%22%2C%20%22.mov%22%7D%20else%20%22audio%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el%20%3D%20ET.Element(tag%2C%20%7B%22src%22%3A%20href%2C%20%22controls%22%3A%20%22%22%2C%20%22preload%22%3A%20%22metadata%22%7D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20elif%20ext%20%3D%3D%20%22.pdf%22%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el%20%3D%20ET.Element(%22iframe%22%2C%20%7B%22src%22%3A%20href%2C%20%22title%22%3A%20label%2C%20%22loading%22%3A%20%22lazy%22%7D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20else%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el%20%3D%20ET.Element(%22span%22%2C%20%7B%22class%22%3A%20%22marimo-obsidian-embed%22%2C%20%22data-obsidian-embed%22%3A%20href%7D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20link%20%3D%20ET.SubElement(el%2C%20%22a%22%2C%20%7B%22href%22%3A%20href%2C%20%22class%22%3A%20%22internal%22%7D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20link.text%20%3D%20AtomicString(label)%5Cn%20%20%20%20%20%20%20%20else%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20el%20%3D%20ET.Element(%22a%22%2C%20%7B%22href%22%3A%20href%2C%20%22class%22%3A%20%22internal%22%2C%20%22data-obsidian-resolved%22%3A%20%22true%22%7D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20el.text%20%3D%20AtomicString(label)%5Cn%20%20%20%20%20%20%20%20return%20el%2C%20match.start(0)%2C%20match.end(0)%5Cn%5Cn%5Cnclass%20Citations(InlineProcessor)%3A%5Cn%20%20%20%20%23%20%60%5B%40key%5D%60%20groups%20were%20formatted%20at%20build%20time%20by%20the%20site%5C's%20citation%20plugin%5Cn%20%20%20%20%23%20(index.js%20scans%20the%20source%20for%20them)%3B%20unknown%20keys%20stay%20literal%2C%20as%20in%20notes.%5Cn%20%20%20%20def%20__init__(self%2C%20md%2C%20citations)%3A%5Cn%20%20%20%20%20%20%20%20super().__init__(r%22(%3F%3C!%5B%5C%5C%5C%5C%5C%5C%5B!%5D)%5C%5C%5B(%3F%3A%5B%5E%5C%5C%5B%5C%5C%5D%5C%5Cn%5D*%3F%5B%5C%5Cs%3B%5D)%3F-%3F%40%5C%5Cw%5B%5E%5C%5C%5B%5C%5C%5D%5C%5Cn%5D*%5C%5C%5D(%3F!%5B%5C%5C%5B(%5C%5C%5D%5D)%22%2C%20md)%5Cn%20%20%20%20%20%20%20%20self.citations%20%3D%20citations%5Cn%5Cn%20%20%20%20def%20handleMatch(self%2C%20match%2C%20data)%3A%5Cn%20%20%20%20%20%20%20%20cited%20%3D%20self.citations.get(match.group(0))%5Cn%20%20%20%20%20%20%20%20if%20cited%20is%20None%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20return%20None%2C%20None%2C%20None%5Cn%20%20%20%20%20%20%20%20return%20self.md.htmlStash.store(cited)%2C%20match.start(0)%2C%20match.end(0)%5Cn%5Cn%5Cnclass%20RawCode(Preprocessor)%3A%5Cn%20%20%20%20def%20run(self%2C%20lines)%3A%5Cn%20%20%20%20%20%20%20%20text%20%3D%20%22%5C%5Cn%22.join(lines)%5Cn%20%20%20%20%20%20%20%20text%20%3D%20re.sub(r%22%3C(code%7Cpre)%5C%5Cb%5B%5E%3E%5D*%3E%5B%5C%5Cs%5C%5CS%5D*%3F%3C%2F%5C%5C1%3E%22%2C%20lambda%20m%3A%20self.md.htmlStash.store(m%5B0%5D)%2C%20text%2C%20flags%3Dre.I)%5Cn%20%20%20%20%20%20%20%20return%20text.split(%22%5C%5Cn%22)%5Cn%5Cn%5Cnclass%20Comments(Preprocessor)%3A%5Cn%20%20%20%20def%20run(self%2C%20lines)%3A%5Cn%20%20%20%20%20%20%20%20%23%20Superfences%20and%20HTML%20blocks%20have%20already%20stashed%20their%20contents.%20Protect%5Cn%20%20%20%20%20%20%20%20%23%20inline%2Findented%20code%20too%3B%20comments%20may%20otherwise%20span%20paragraphs.%5Cn%20%20%20%20%20%20%20%20text%20%3D%20%22%5C%5Cn%22.join(lines)%5Cn%20%20%20%20%20%20%20%20definitions%20%3D%20%5B%5D%5Cn%20%20%20%20%20%20%20%20pattern%20%3D%20(%5Cn%20%20%20%20%20%20%20%20%20%20%20%20r%22(%3FP%3Ccode%3E(%3FP%3Cticks%3E%60%2B)%5B%5C%5Cs%5C%5CS%5D*%3F(%3FP%3Dticks)(%3F!%60)%7C%5E(%3F%3A%20%7B4%7D%7C%5C%5Ct)%5B%5E%5C%5Cn%5D*)%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20r%22%7C(%3FP%3Ccomment%3E(%3F%3C!%5C%5C%5C%5C)%25%25%5B%5C%5Cs%5C%5CS%5D*%3F(%3F%3C!%5C%5C%5C%5C)%25%25)%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20r%22%7C(%3F%3C!%5C%5C%5C%5C)%5C%5C%5E%5C%5C%5B(%3FP%3Cfootnote%3E(%3F%3A%5B%5E%5C%5C%5B%5C%5C%5D%5C%5Cn%5D%7C%5C%5C%5B%5B%5E%5C%5C%5D%5C%5Cn%5D*%5C%5C%5D)%2B)%5C%5C%5D%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20r%22%7C(%3FP%3Ctask%3E%5E%5B%20%5C%5Ct%5D*%5B-*%2B%5D%20%5C%5C%5B)%5B%5E%20%5C%5C%5DxX%5D(%3F%3D%5C%5C%5D%20)%22%5Cn%20%20%20%20%20%20%20%20)%5Cn%20%20%20%20%20%20%20%20def%20replace(match)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20match.group(%22code%22)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20match.group(0)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20match.group(%22comment%22)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20%22%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20match.group(%22task%22)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20match.group(%22task%22)%20%2B%20%22x%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20name%20%3D%20f%22ewan-inline-%7Blen(definitions)%20%2B%201%7D%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20definitions.append(f%22%5B%5E%7Bname%7D%5D%3A%20%7Bmatch.group(%5C'footnote%5C')%7D%22)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20return%20f%22%5B%5E%7Bname%7D%5D%22%5Cn%20%20%20%20%20%20%20%20text%20%3D%20re.sub(pattern%2C%20replace%2C%20text%2C%20flags%3Dre.M)%5Cn%20%20%20%20%20%20%20%20return%20(text%20%2B%20%22%5C%5Cn%5C%5Cn%22%20%2B%20%22%5C%5Cn%22.join(definitions)).split(%22%5C%5Cn%22)%5Cn%5Cn%5Cn%5Cnclass%20Callouts(Treeprocessor)%3A%5Cn%20%20%20%20def%20run(self%2C%20root)%3A%5Cn%20%20%20%20%20%20%20%20%23%20Before%20inline%20parsing%20so%20titles%20retain%20bold%2C%20links%20and%20other%20Markdown.%5Cn%20%20%20%20%20%20%20%20for%20el%20in%20list(root.iter())%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20el.tag%20!%3D%20%22blockquote%22%20or%20not%20len(el)%20or%20el%5B0%5D.tag%20!%3D%20%22p%22%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20continue%5Cn%20%20%20%20%20%20%20%20%20%20%20%20first%20%3D%20el%5B0%5D%5Cn%20%20%20%20%20%20%20%20%20%20%20%20match%20%3D%20re.match(r%22%5E%5C%5C%5B!(%5B%5C%5Cw-%5D%2B)%5C%5C%5D(%5B%2B-%5D%3F)%5B%20%5C%5Ct%5D*(%5B%5E%5C%5Cn%5D*)(%3F%3A%5C%5Cn%7C%24)%22%2C%20first.text%20or%20%22%22)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20match%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20continue%5Cn%20%20%20%20%20%20%20%20%20%20%20%20kind%2C%20fold%2C%20title%20%3D%20match.groups()%5Cn%20%20%20%20%20%20%20%20%20%20%20%20el.tag%20%3D%20%22details%22%20if%20fold%20else%20%22div%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22class%22%2C%20%22callout%22)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22data-callout%22%2C%20kind.lower())%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20fold%20%3D%3D%20%22%2B%22%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22open%22%2C%20%22%22)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20first.text%20%3D%20(first.text%20or%20%22%22)%5Bmatch.end()%3A%5D%5Cn%20%20%20%20%20%20%20%20%20%20%20%20title_el%20%3D%20ET.Element(%22summary%22%20if%20fold%20else%20%22div%22%2C%20%7B%22class%22%3A%20%22callout-title%22%7D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20title_el.text%20%3D%20title%20or%20kind.capitalize()%5Cn%20%20%20%20%20%20%20%20%20%20%20%20el.insert(0%2C%20title_el)%5Cn%20%20%20%20%20%20%20%20return%20root%5Cn%5Cn%5Cnclass%20ObsidianTree(Treeprocessor)%3A%5Cn%20%20%20%20def%20__init__(self%2C%20md%2C%20resolver)%3A%5Cn%20%20%20%20%20%20%20%20super().__init__(md)%5Cn%20%20%20%20%20%20%20%20self.resolver%20%3D%20resolver%5Cn%5Cn%20%20%20%20def%20run(self%2C%20root)%3A%5Cn%20%20%20%20%20%20%20%20%23%20After%20inline%20parsing%3A%20syntax%20in%20code%20and%20raw%20HTML%20remains%20literal.%5Cn%20%20%20%20%20%20%20%20for%20parent%20in%20list(root.iter())%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20parent.tag%20in%20%7B%22code%22%2C%20%22pre%22%7D%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20continue%5Cn%20%20%20%20%20%20%20%20%20%20%20%20for%20i%2C%20child%20in%20enumerate(list(parent))%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20child.tag%20in%20%7B%22p%22%2C%20%22li%22%2C%20%22blockquote%22%7D%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20parts%20%3D%20%5B(child%2C%20%22text%22)%5D%20%2B%20%5B(e%2C%20%22tail%22)%20for%20e%20in%20child.iter()%5D%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20el%2C%20attr%20in%20reversed(parts)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20text%20%3D%20getattr(el%2C%20attr)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20text%20or%20not%20text.strip()%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20continue%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20marker%20%3D%20re.search(r%22(%3F%3A%5E%7C%5C%5Cs)%5C%5C%5E(%5BA-Za-z0-9-%5D%2B)%5C%5Cs*%24%22%2C%20text)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20marker%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20setattr(el%2C%20attr%2C%20text%5B%3Amarker.start()%5D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dest%20%3D%20child%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20child.tag%20%3D%3D%20%22p%22%20and%20not%20%22%22.join(child.itertext()).strip()%20and%20i%20%3E%200%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dest%20%3D%20parent%5Bi%20-%201%5D%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20parent.remove(child)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dest.set(%22id%22%2C%20marker%5B1%5D.lower())%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20break%5Cn%20%20%20%20%20%20%20%20for%20el%20in%20list(root.iter())%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20el.tag%20%3D%3D%20%22p%22%20and%20el.get(%22id%22)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Native%20marimo%20rewrites%20bare%20%3Cp%3E%20but%20every%20%3C%2Fp%3E%3B%20keep%20IDs%20valid.%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.tag%20%3D%20%22span%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22class%22%2C%20%22paragraph%22)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20if%20el.tag%20in%20%7B%22a%22%2C%20%22img%22%7D%20and%20not%20el.get(%22data-obsidian-resolved%22)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20attr%20%3D%20%22href%22%20if%20el.tag%20%3D%3D%20%22a%22%20else%20%22src%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20url%20%3D%20el.get(attr%2C%20%22%22)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20el.tag%20%3D%3D%20%22img%22%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alt%20%3D%20el.get(%22alt%22%2C%20%22%22)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dimensions%20%3D%20re.search(r%22%5C%5C%7C(%5C%5Cd%2B)(%3F%3Ax(%5C%5Cd%2B))%3F%24%22%2C%20alt)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20dimensions%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22alt%22%2C%20alt%5B%3Adimensions.start()%5D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22width%22%2C%20dimensions%5B1%5D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20dimensions%5B2%5D%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22height%22%2C%20dimensions%5B2%5D)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Footnotes%20and%20generated%20TOC%20anchors%20already%20use%20rendered%20IDs.%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20url%20or%20(url.startswith(%22%23%22)%20and%20(%22footnote%22%20in%20el.get(%22class%22%2C%20%22%22)%20or%20url.startswith(%22%23fn%22)))%20or%20re.match(r%22%5E%5Ba-zA-Z%5D%5B%5C%5Cw%2B.-%5D*%3A%22%2C%20url)%20or%20url.startswith(%22%2F%2F%22)%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20continue%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20href%2C%20entry%20%3D%20self.resolver.resolve(url)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20href%20is%20not%20None%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.set(attr%2C%20href)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20el.tag%20%3D%3D%20%22a%22%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22class%22%2C%20%22internal%22)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20elif%20el.tag%20%3D%3D%20%22a%22%3A%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.attrib.pop(%22href%22%2C%20None)%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.tag%20%3D%20%22span%22%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20el.set(%22class%22%2C%20%22internal-link%20is-unresolved%22)%5Cn%5Cn%20%20%20%20%20%20%20%20return%20root%5Cn%5Cn%5Cnclass%20ObsidianExtension(Extension)%3A%5Cn%20%20%20%20def%20__init__(self%2C%20resolver%2C%20citations)%3A%5Cn%20%20%20%20%20%20%20%20self.resolver%20%3D%20resolver%5Cn%20%20%20%20%20%20%20%20self.citations%20%3D%20citations%5Cn%20%20%20%20%20%20%20%20super().__init__()%5Cn%5Cn%20%20%20%20def%20extendMarkdown(self%2C%20md)%3A%5Cn%20%20%20%20%20%20%20%20md.preprocessors.register(RawCode(md)%2C%20%22obsidian-raw-code%22%2C%2024.5)%5Cn%20%20%20%20%20%20%20%20md.preprocessors.register(Comments(md)%2C%20%22obsidian-comments%22%2C%2019)%5Cn%20%20%20%20%20%20%20%20md.inlinePatterns.register(WikiLinks(md%2C%20self.resolver)%2C%20%22obsidian-wikilinks%22%2C%20181)%5Cn%20%20%20%20%20%20%20%20md.inlinePatterns.register(Citations(md%2C%20self.citations)%2C%20%22obsidian-citations%22%2C%20175)%5Cn%20%20%20%20%20%20%20%20md.treeprocessors.register(Callouts(md)%2C%20%22obsidian-callouts%22%2C%2026)%5Cn%20%20%20%20%20%20%20%20md.treeprocessors.register(ObsidianTree(md%2C%20self.resolver)%2C%20%22obsidian-tree%22%2C%206)%5Cn%5Cn%5Cndef%20install(context)%3A%5Cn%20%20%20%20import%20importlib%5Cn%20%20%20%20import%20marimo%5Cn%20%20%20%20native%20%3D%20importlib.import_module(%22marimo._output.md%22)%5Cn%20%20%20%20extensions%20%3D%20%5Be%20for%20e%20in%20native._get_extensions()%20if%20e%20not%20in%20(%22pymdownx.caret%22%2C%20%22pymdownx.critic%22)%5D%5Cn%20%20%20%20config%20%3D%20%7Bk%3A%20dict(v)%20for%20k%2C%20v%20in%20native._get_extension_configs().items()%7D%5Cn%20%20%20%20config%5B%22toc%22%5D%20%3D%20%7B%22slugify%22%3A%20heading_slug%7D%5Cn%20%20%20%20config%5B%22pymdownx.tilde%22%5D%20%3D%20%7B%22subscript%22%3A%20False%7D%5Cn%20%20%20%20config%5B%22pymdownx.superfences%22%5D%5B%22custom_fences%22%5D%20%3D%20%5B%7B%5Cn%20%20%20%20%20%20%20%20%22name%22%3A%20%22mermaid%22%2C%20%22class%22%3A%20%22mermaid%22%2C%5Cn%20%20%20%20%20%20%20%20%22format%22%3A%20lambda%20source%2C%20language%2C%20class_name%2C%20options%2C%20md%2C%20**kwargs%3A%20marimo.mermaid(source).text%2C%5Cn%20%20%20%20%7D%5D%5Cn%20%20%20%20md%20%3D%20Markdown(extensions%3D%5B*extensions%2C%20%22pymdownx.mark%22%2C%20ObsidianExtension(Resolver(context)%2C%20context.get(%22citations%22%2C%20%7B%7D))%5D%2C%20extension_configs%3Dconfig)%5Cn%20%20%20%20lock%20%3D%20threading.Lock()%5Cn%20%20%20%20native._get_markdown%20%3D%20lambda%3A%20(md%2C%20lock)%5Cn'%2C%20_obsidian_namespace)%0A_obsidian_namespace%5B'install'%5D(_obsidian_json.loads('%7B%22currentSlug%22%3A%20%22notes%2Fmodeling-complex-systems%2Fstability_and_generalized_lv%22%2C%20%22index%22%3A%20%22%2Fstatic%2Fmarimo-links.json%3Fv%3D79a7f08ced79%22%7D'))%0Aewan_obsidian_ready%20%3D%20True
ewan_obsidian_ready%0Aimport%20marimo%20as%20mo%0Aimport%20numpy%20as%20np%0Aimport%20plotly.graph_objects%20as%20go%0Afrom%20plotly.subplots%20import%20make_subplots%0Afrom%20scipy.integrate%20import%20solve_ivp%0Afrom%20scipy.linalg%20import%20expm%0Afrom%20scipy.signal%20import%20find_peaks%0Afrom%20wigglystuff%20import%20TangleLatex
ewan_obsidian_ready%0Aimport%20re%0Afrom%20urllib.parse%20import%20urlencode%0A%0Avault_link_paths%20%3D%20%7B'Andronov%20Hopf%20Bifurcation'%3A%20'Notes%2FChaos%20Theory%2FAndronov%20Hopf%20Bifurcation.md'%2C%20'Eulers%20Method'%3A%20'Notes%2FSelfstudy%20Mathematics%2FDifferential%2FNumerical%20Approx%20Methods%2FEulers%20Method.md'%2C%20'Finite-Time%20Lyapunov%20Exponent'%3A%20'Notes%2FChaos%20Theory%2FFinite-Time%20Lyapunov%20Exponent.md'%2C%20'Fixed%20Point%20Classification'%3A%20'Notes%2FChaos%20Theory%2FFixed%20Point%20Classification.md'%2C%20'Limit%20Cycle'%3A%20'Notes%2FChaos%20Theory%2FLimit%20Cycle.md'%2C%20'Linearization%20and%20the%20Jacobian'%3A%20'Notes%2FChaos%20Theory%2FLinearization%20and%20the%20Jacobian.md'%2C%20'Local%20Lyapunov%20Exponent'%3A%20'Notes%2FChaos%20Theory%2FLocal%20Lyapunov%20Exponent.md'%2C%20'Logistic%20Map'%3A%20'Notes%2FSelfstudy%20Mathematics%2FLogistic%20Map.md'%2C%20'Lyapunov%20Exponents'%3A%20'Notes%2FChaos%20Theory%2FLyapunov%20Exponents.md'%2C%20'Saddle%20fixed%20point'%3A%20'Notes%2FChaos%20Theory%2FSaddle%20fixed%20point.md'%2C%20'Sensitive%20Dependence%20on%20Initial%20Conditions'%3A%20'Notes%2FChaos%20Theory%2FSensitive%20Dependence%20on%20Initial%20Conditions.md'%2C%20'Sinks%2C%20Sources%2C%20and%20Saddles'%3A%20'Notes%2FChaos%20Theory%2FSinks%2C%20Sources%2C%20and%20Saddles.md'%2C%20'Stable%20and%20Unstable%20Manifolds'%3A%20'Notes%2FChaos%20Theory%2FStable%20and%20Unstable%20Manifolds.md'%2C%20'continuous_models.marimo'%3A%20'Notes%2FModeling%20Complex%20Systems%2Fcontinuous_models.marimo.py'%2C%20'lotka_volterra.marimo'%3A%20'Notes%2FModeling%20Complex%20Systems%2Flotka_volterra.marimo.py'%7D%0A%0Adef%20note_md(text)%3A%0A%20%20%20%20%22%22%22Keep%20wiki%20notation%20in%20source%3B%20render%20usable%20Obsidian%20links%20in%20standalone%20marimo.%22%22%22%0A%20%20%20%20def%20replace_link(match)%3A%0A%20%20%20%20%20%20%20%20target%2C%20_%2C%20label%20%3D%20match.group(1).partition('%7C')%0A%20%20%20%20%20%20%20%20path%20%3D%20vault_link_paths.get(target)%0A%20%20%20%20%20%20%20%20if%20path%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20match.group(0)%0A%20%20%20%20%20%20%20%20url%20%3D%20'obsidian%3A%2F%2Fopen%3F'%20%2B%20urlencode(%7B'vault'%3A'VAULT'%2C'file'%3Apath%7D)%0A%20%20%20%20%20%20%20%20return%20f'%5B%7Blabel%20or%20target%7D%5D(%7Burl%7D)'%0A%20%20%20%20text%20%3D%20re.sub(r'%5C%5B%5C%5B(%5B%5E%5C%5D%5D%2B)%5C%5D%5C%5D'%2C%20replace_link%2C%20text)%0A%20%20%20%20%23%20Display%20math%20needs%20standalone%20delimiters%3B%20preserve%20inline%20single-dollar%20math.%0A%20%20%20%20text%20%3D%20re.sub(r'%5C%24%5C%24(.*%3F)%5C%24%5C%24'%2C%20lambda%20m%3A%20'%5Cn%5Cn%24%24%5Cn'%2Bm.group(1).strip()%2B'%5Cn%24%24%5Cn%5Cn'%2C%20text%2C%20flags%3Dre.S)%0A%20%20%20%20return%20mo.md(text)%0A
ewan_obsidian_ready%0Anote_md(r%22%22%22%0A%23%23%20Stability%20and%20generalized%20Lotka%E2%80%93Volterra%0A%0ASeptember%2024%20%C2%B7%20%5B%5Bcontinuous_models.marimo%7CContinuous%20models%5D%5D%20%C2%B7%20%5B%5Blotka_volterra.marimo%7CLotka%E2%80%93Volterra%5D%5D%0A%22%22%22)
ewan_obsidian_ready%0A%23%20Theme%20snapshot%20compiled%20from%20EWAN_THEME_DIR%2Ftheme.json%20(ewan-default%20v1).%0A%23%20The%20dotfiles%20theme%20remains%20the%20authority%3B%20no%20local%20theme%20configuration%20is%20required.%0Acolors%20%3D%20%7B'light'%3A%20'%23f5f1eb'%2C%20'lightgray'%3A%20'%23e6dfd6'%2C%20'gray'%3A%20'%239a8f82'%2C%20'darkgray'%3A%20'%234a4238'%2C%20'dark'%3A%20'%232d2520'%2C%20'secondary'%3A%20'%23a67c6d'%2C%20'tertiary'%3A%20'%238b7f73'%2C%20'rust'%3A%20'%23bf6159'%2C%20'clay'%3A%20'%23c78d75'%2C%20'ochre'%3A%20'%23cc9e54'%2C%20'sage'%3A%20'%23869c7a'%2C%20'pine'%3A%20'%2356706b'%2C%20'slate'%3A%20'%23728c99'%2C%20'mauve'%3A%20'%239d868e'%7D%0Aspecies_colors%20%3D%20%5Bcolors%5B'slate'%5D%2C%20colors%5B'rust'%5D%2C%20colors%5B'pine'%5D%5D%0Adef%20style(fig%2C%20height%3D380)%3A%0A%20%20%20%20fig.update_layout(template%3D'plotly_white'%2C%20height%3Dheight%2C%0A%20%20%20%20%20%20%20%20paper_bgcolor%3Dcolors%5B'light'%5D%2C%20plot_bgcolor%3Dcolors%5B'light'%5D%2C%0A%20%20%20%20%20%20%20%20font%3Ddict(family%3D'PP%20Neue%20Montreal%2C%20Arial%2C%20sans-serif'%2Ccolor%3Dcolors%5B'dark'%5D)%2C%0A%20%20%20%20%20%20%20%20colorway%3Dspecies_colors%2C%20margin%3Ddict(l%3D55%2Cr%3D25%2Ct%3D45%2Cb%3D50)%2C%0A%20%20%20%20%20%20%20%20legend%3Ddict(orientation%3D'h'%2C%20y%3D1.13)%2C%20hovermode%3D'closest')%0A%20%20%20%20fig.update_xaxes(gridcolor%3Dcolors%5B'lightgray'%5D%2C%20zerolinecolor%3Dcolors%5B'gray'%5D)%0A%20%20%20%20fig.update_yaxes(gridcolor%3Dcolors%5B'lightgray'%5D%2C%20zerolinecolor%3Dcolors%5B'gray'%5D)%0A%20%20%20%20return%20fig%0A%0Adef%20tangle(latex%2C%20parameters)%3A%0A%20%20%20%20return%20mo.ui.anywidget(TangleLatex(latex%3Dlatex%2C%20parameters%3Dparameters%2C%20theme%3D'light'))%0A%0Adef%20parameter(value%2C%20low%2C%20high%2C%20step%3D0.1%2C%20digits%3D2)%3A%0A%20%20%20%20return%20dict(value%3Dvalue%2Cmin_value%3Dlow%2Cmax_value%3Dhigh%2Cstep%3Dstep%2Cdigits%3Ddigits)
ewan_obsidian_ready%0Anote_md(r%22%22%22%0A%5B%5BLinearization%20and%20the%20Jacobian%5D%5D%20describes%20local%20dynamics%20through%20the%20derivative%20at%20a%20fixed%20point.%20For%20a%20discrete%20map%20%24x_%7Bn%2B1%7D%3Dg(x_n)%24%2C%20a%20fixed%20point%20satisfies%20%24g(x%5E*)%3Dx%5E*%24%20and%20a%20small%20perturbation%20evolves%20by%20%24%5Ceta_%7Bn%2B1%7D%5Capprox%20Dg(x%5E*)%5Ceta_n%24.%20For%20a%20flow%20%24%5Cdot%20x%3Df(x)%24%2C%20the%20fixed-point%20condition%20is%20%24f(x%5E*)%3D0%24%20and%20the%20corresponding%20linear%20system%20is%20%24%5Cdot%5Ceta%3DJ(x%5E*)%5Ceta%24.%20Same%20local%20approximation%2C%20different%20stability%20condition%3A%20a%20map%20contracts%20when%20all%20%24%5Clvert%5Clambda(Dg)%5Crvert%3C1%24%3B%20a%20flow%20is%20asymptotically%20stable%20when%20all%20%24%5Coperatorname%7BRe%7D%5Clambda(J)%3C0%24.%20See%20%5B%5BFixed%20Point%20Classification%5D%5D.%0A%0AThe%20time-%24h%24%20flow%20map%20has%20derivative%20%24e%5E%7BhJ%7D%24%20at%20the%20fixed%20point%2C%20with%20multipliers%20%24e%5E%7Bh%5Clambda%7D%24.%20Negative%20real%20parts%20therefore%20give%20magnitudes%20below%20one.%20%5B%5BEulers%20Method%5D%5D%20approximates%20this%20map%20by%20%24I%2BhJ%24%2C%20so%20its%20multipliers%20are%20%241%2Bh%5Clambda%24%3B%20these%20can%20leave%20the%20unit%20disk%20even%20when%20the%20continuous%20system%20is%20stable.%0A%22%22%22)
ewan_obsidian_ready%0Anote_md(r%22%22%22%0A%23%23%23%20Time%20and%20state%20derivatives%0A%0AFor%20the%20continuous%20logistic%20equation%2C%0A%24%24%5Cdot%20x%3Df(x)%3Drx(1-x)%2C%5Cqquad%20f'(x)%3Dr(1-2x).%24%24%0AThe%20graph%20of%20%24x(t)%24%20has%20slope%20%24f(x)%24%3B%20the%20graph%20of%20%24f(x)%24%20has%20slope%20%24f'(x)%24.%20Thus%20%24f'(x)%3C0%24%20means%20an%20increase%20in%20population%20reduces%20growth%20velocity.%20Population%20still%20increases%20wherever%20%24f(x)%3E0%24%2C%20as%20it%20does%20for%20%241%2F2%3Cx%3C1%24.%20These%20are%20derivatives%20of%20different%20functions%2C%20even%20though%20both%20are%20evaluated%20at%20the%20same%20state.%20The%20discrete%20%5B%5BLogistic%20Map%5D%5D%20instead%20advances%20the%20state%20by%20iteration.%0A%22%22%22)
ewan_obsidian_ready%0Ascalar_inputs%20%3D%20tangle(r%22r%3D%5Ctangle%7Br%7D%2C%5Cquad%20x_0%3D%5Ctangle%7Bx0%7D%2C%5Cquad%20t_%7B%5Crm%20inspect%7D%3D%5Ctangle%7Btime%7D%2C%5Cquad%5Cdelta%20x%3D%5Ctangle%7Bdx%7D%22%2C%0A%20%20%20%20dict(r%3Dparameter(1%2C0.2%2C2)%2Cx0%3Dparameter(0.15%2C0.05%2C1.8%2C0.05)%2C%0A%20%20%20%20%20%20%20%20%20time%3Dparameter(2%2C0%2C8)%2Cdx%3Dparameter(0.1%2C0.01%2C0.4%2C0.01)))%0Ascalar_inputs
ewan_obsidian_ready%0Ascalar_values%20%3D%20dict(scalar_inputs.values)%0Ascalar_r%20%3D%20scalar_values%5B'r'%5D%0Ascalar_t0%20%3D%20scalar_values%5B'time'%5D%0Ascalar_time%20%3D%20np.linspace(0%2C8%2C401)%0Adef%20logistic_exact(t)%3A%0A%20%20%20%20return%201%2F(1%2B(1%2Fscalar_values%5B'x0'%5D-1)*np.exp(-scalar_r*np.asarray(t)))%0Ascalar_states%20%3D%20logistic_exact(scalar_time)%0Ascalar_probe%20%3D%20float(logistic_exact(scalar_t0))%0Ascalar_velocity%20%3D%20scalar_r*scalar_probe*(1-scalar_probe)%0Ascalar_derivative%20%3D%20scalar_r*(1-2*scalar_probe)%0Ascalar_dx%20%3D%20scalar_values%5B'dx'%5D%0Ascalar_velocity_change%20%3D%20scalar_r*(scalar_probe%2Bscalar_dx)*(1-scalar_probe-scalar_dx)-scalar_velocity%0Ascalar_predicted_change%20%3D%20scalar_derivative*scalar_dx
ewan_obsidian_ready%0A_fig%20%3D%20make_subplots(rows%3D1%2Ccols%3D2%2Csubplot_titles%3D('State%20over%20time%3A%20slope%20is%20f(x)'%2C'Velocity%20over%20state%3A%20slope%20is%20f%E2%80%B2(x)'))%0A_fig.add_trace(go.Scatter(x%3Dscalar_time%2Cy%3Dscalar_states%2Cname%3D'x(t)'%2Cline%3Ddict(color%3Dcolors%5B'slate'%5D))%2C1%2C1)%0A_dt%20%3D%20np.array(%5B-0.7%2C0.7%5D)%0A_fig.add_trace(go.Scatter(x%3Dscalar_t0%2B_dt%2Cy%3Dscalar_probe%2Bscalar_velocity*_dt%2Cname%3D'Time%20tangent'%2Cline%3Ddict(color%3Dcolors%5B'rust'%5D%2Cdash%3D'dash'))%2C1%2C1)%0A_fig.add_trace(go.Scatter(x%3D%5Bscalar_t0%5D%2Cy%3D%5Bscalar_probe%5D%2Cmode%3D'markers'%2Cshowlegend%3DFalse%2Cmarker%3Ddict(size%3D9%2Ccolor%3Dcolors%5B'dark'%5D))%2C1%2C1)%0A_x%20%3D%20np.linspace(0%2C2%2C401)%0A_fig.add_trace(go.Scatter(x%3D_x%2Cy%3Dscalar_r*_x*(1-_x)%2Cname%3D'f(x)'%2Cline%3Ddict(color%3Dcolors%5B'pine'%5D))%2C1%2C2)%0A_xlocal%20%3D%20scalar_probe%2Bnp.array(%5B-0.4%2C0.4%5D)%0A_fig.add_trace(go.Scatter(x%3D_xlocal%2Cy%3Dscalar_velocity%2Bscalar_derivative*(_xlocal-scalar_probe)%2Cname%3D'State%20tangent'%2Cline%3Ddict(color%3Dcolors%5B'rust'%5D%2Cdash%3D'dash'))%2C1%2C2)%0A_fig.add_trace(go.Scatter(x%3D%5Bscalar_probe%2Cscalar_probe%2Bscalar_dx%5D%2Cy%3D%5Bscalar_velocity%2Cscalar_velocity%2Bscalar_velocity_change%5D%2Cmode%3D'markers%2Blines'%2Cname%3D'Finite%20state%20increment'%2Cline%3Ddict(color%3Dcolors%5B'ochre'%5D))%2C1%2C2)%0A_fig.add_trace(go.Scatter(x%3D%5B0%2C1%5D%2Cy%3D%5B0%2C0%5D%2Cmode%3D'markers'%2Cname%3D'Fixed%20points'%2Cmarker%3Ddict(symbol%3D'diamond'%2Csize%3D8%2Ccolor%3Dcolors%5B'dark'%5D))%2C1%2C2)%0A_fig.add_hline(y%3D0%2Crow%3D1%2Ccol%3D2)%0A_fig.update_xaxes(title_text%3D'Time%20t'%2Crange%3D%5B0%2C8%5D%2Crow%3D1%2Ccol%3D1)%0A_fig.update_yaxes(title_text%3D'State%20x'%2Crow%3D1%2Ccol%3D1)%0A_fig.update_xaxes(title_text%3D'State%20x'%2Crange%3D%5B0%2C2%5D%2Crow%3D1%2Ccol%3D2)%0A_fig.update_yaxes(title_text%3D'Velocity%20dx%2Fdt'%2Crow%3D1%2Ccol%3D2)%0Amo.vstack(%5Bstyle(_fig%2C370)%2Cnote_md(rf%22%22%22%0AAt%20%24x%3D%7Bscalar_probe%3A.3f%7D%24%2C%20%24%5Cdot%20x%3D%7Bscalar_velocity%3A.3f%7D%24%20and%20%24d%5Cdot%20x%2Fdx%3D%7Bscalar_derivative%3A.3f%7D%24.%20A%20displacement%20%24%5Cdelta%20x%3D%7Bscalar_dx%3A.2f%7D%24%20changes%20the%20velocity%20by%20%7Bscalar_velocity_change%3A.4f%7D%3B%20linearization%20gives%20%24f'(x)%5Cdelta%20x%3D%7Bscalar_predicted_change%3A.4f%7D%24%2C%20with%20exact%20remainder%20%24-r(%5Cdelta%20x)%5E2%3D%7B-scalar_r*scalar_dx**2%3A.4f%7D%24.%20Differentiation%20along%20time%20introduces%20another%20factor%20through%20the%20chain%20rule%3A%0A%24%24%5Cddot%20x%3D%5Cfrac%7B%7Bdf%7D%7D%7B%7Bdx%7D%7D%5Cfrac%7B%7Bdx%7D%7D%7B%7Bdt%7D%7D%3Df'(x)f(x)%3D%7Bscalar_derivative*scalar_velocity%3A.4f%7D.%24%24%0AAt%20a%20fixed%20point%2C%20the%20sign%20of%20%24f'%24%20determines%20linear%20stability%3A%20%24f'(0)%3Dr%3E0%24%20gives%20a%20source%20and%20%24f'(1)%3D-r%3C0%24%20gives%20a%20sink.%20With%20dimensionless%20%24x%24%2C%20both%20%24f%24%20and%20%24f'%24%20have%20units%20of%20inverse%20time%2C%20while%20%24%5Cddot%20x%24%20has%20units%20of%20inverse%20time%20squared.%0A%22%22%22)%5D)
ewan_obsidian_ready%0Anote_md(r%22%22%22%0A%23%23%23%20Predator%E2%80%93prey%20nullclines%0A%0ALet%20%24F%24%20and%20%24S%24%20denote%20fish%20and%20shark%20populations%2C%20with%20unit%20conversion%20from%20consumed%20fish%20to%20new%20sharks%3A%0A%24%24%5Cdot%20F%3D%5Cmu%20F-%5Cbeta%20FS%2C%5Cqquad%20%5Cdot%20S%3D%5Cbeta%20FS-%5Cnu%20S.%24%24%0AA%20**nullcline**%20is%20the%20set%20where%20one%20velocity%20component%20vanishes.%20Intersections%20of%20the%20two%20nullcline%20sets%20are%20%5B%5BFixed%20Point%20Classification%7Cfixed%20points%5D%5D%2C%20since%20both%20populations%20are%20stationary%20there%3A%0A%24%24%5Cdot%20F%3D0%3A%5C%20F%3D0%5C%20%5Ctext%7Bor%7D%5C%20S%3D%5Cmu%2F%5Cbeta%2C%5Cqquad%0A%5Cdot%20S%3D0%3A%5C%20S%3D0%5C%20%5Ctext%7Bor%7D%5C%20F%3D%5Cnu%2F%5Cbeta.%24%24%0AFor%20positive%20rates%2C%20the%20fixed%20points%20are%20%24(0%2C0)%24%20and%20%24(%5Cnu%2F%5Cbeta%2C%5Cmu%2F%5Cbeta)%24.%20Coordinates%20below%20are%20ordered%20%24(F%2CS)%24.%0A%22%22%22)
ewan_obsidian_ready%0Afish_inputs%20%3D%20tangle(%0A%20%20%20%20r%22%5Cmu%3D%5Ctangle%7Bmu%7D%2C%5Cquad%5Cnu%3D%5Ctangle%7Bnu%7D%2C%5Cquad%5Cbeta%3D%5Ctangle%7Bbeta%7D%2C%5Cqquad%20F_0%3D%5Ctangle%7Bf0%7D%2C%5Cquad%20S_0%3D%5Ctangle%7Bs0%7D%22%2C%0A%20%20%20%20dict(mu%3Dparameter(1%2C0.2%2C2)%2Cnu%3Dparameter(0.7%2C0.2%2C2)%2Cbeta%3Dparameter(0.5%2C0.1%2C1)%2C%0A%20%20%20%20%20%20%20%20%20f0%3Dparameter(1%2C0.1%2C6)%2Cs0%3Dparameter(1%2C0.1%2C6)))%0Afish_inputs
ewan_obsidian_ready%0Adef%20fish_rhs(t%2C%20state%2C%20mu%2C%20nu%2C%20beta)%3A%0A%20%20%20%20F%2C%20S%20%3D%20state%0A%20%20%20%20return%20np.array(%5BF*(mu-beta*S)%2C%20S*(beta*F-nu)%5D)%0A%0Adef%20fish_jacobian(state%2C%20mu%2C%20nu%2C%20beta)%3A%0A%20%20%20%20F%2C%20S%20%3D%20state%0A%20%20%20%20return%20np.array(%5B%5Bmu-beta*S%2C-beta*F%5D%2C%5Bbeta*S%2Cbeta*F-nu%5D%5D)%0A%0Adef%20fish_integral(states%2C%20mu%2C%20nu%2C%20beta)%3A%0A%20%20%20%20F%2C%20S%20%3D%20np.asarray(states).T%0A%20%20%20%20return%20beta*(F%2BS)-nu*np.log(F)-mu*np.log(S)
ewan_obsidian_ready%0Afish_parameters%20%3D%20dict(fish_inputs.values)%0Amu%2C%20nu%2C%20beta%20%3D%20(fish_parameters%5Bk%5D%20for%20k%20in%20('mu'%2C'nu'%2C'beta'))%0Afish_initial%20%3D%20np.array(%5Bfish_parameters%5B'f0'%5D%2Cfish_parameters%5B's0'%5D%5D)%0Afish_time%20%3D%20np.linspace(0%2C30%2C1201)%0Afish_solution%20%3D%20solve_ivp(fish_rhs%2C(0%2C30)%2Cfish_initial%2Cargs%3D(mu%2Cnu%2Cbeta)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20t_eval%3Dfish_time%2Cmethod%3D'DOP853'%2Crtol%3D1e-10%2Catol%3D1e-12)%0Aif%20not%20fish_solution.success%3A%0A%20%20%20%20raise%20RuntimeError(fish_solution.message)%0Afish_states%20%3D%20fish_solution.y.T%0Afish_fixed%20%3D%20np.array(%5Bnu%2Fbeta%2Cmu%2Fbeta%5D)%0Afish_H%20%3D%20fish_integral(fish_states%2Cmu%2Cnu%2Cbeta)
ewan_obsidian_ready%0A_fig%20%3D%20go.Figure()%0A_upper%20%3D%20np.maximum(fish_states.max(axis%3D0)*1.1%2Cfish_fixed*1.5)%0A_f%2C%20_s%20%3D%20np.meshgrid(np.linspace(0%2C_upper%5B0%5D%2C13)%2Cnp.linspace(0%2C_upper%5B1%5D%2C13))%0A_u%2C%20_v%20%3D%20_f*(mu-beta*_s)%2C%20_s*(beta*_f-nu)%0A_norm%20%3D%20np.hypot(_u%2F_upper%5B0%5D%2C_v%2F_upper%5B1%5D)%0A_scale%20%3D%200.035%2Fnp.maximum(_norm%2C1e-12)%0Afor%20_x%2C_y%2C_dx%2C_dy%20in%20zip(_f.flat%2C_s.flat%2C(_u*_scale).flat%2C(_v*_scale).flat)%3A%0A%20%20%20%20_fig.add_annotation(x%3D_x%2B_dx%2Cy%3D_y%2B_dy%2Cax%3D_x%2Cay%3D_y%2Cxref%3D'x'%2Cyref%3D'y'%2Caxref%3D'x'%2Cayref%3D'y'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20showarrow%3DTrue%2Carrowhead%3D2%2Carrowsize%3D0.7%2Carrowwidth%3D1%2Carrowcolor%3Dcolors%5B'gray'%5D)%0A_fig.add_trace(go.Scatter(x%3Dfish_states%5B%3A%2C0%5D%2Cy%3Dfish_states%5B%3A%2C1%5D%2Cmode%3D'lines%2Bmarkers'%2C%0A%20%20%20%20marker%3Ddict(size%3D3%2Ccolor%3Dfish_time%2Ccolorscale%3D'Viridis'%2Cshowscale%3DFalse)%2C%0A%20%20%20%20line%3Ddict(color%3Dcolors%5B'pine'%5D%2Cwidth%3D1)%2Ccustomdata%3Dnp.arange(len(fish_time))%2C%0A%20%20%20%20name%3D'Orbit'%2Chovertemplate%3D'F%3D%25%7Bx%3A.3f%7D%3Cbr%3ES%3D%25%7By%3A.3f%7D%3Cextra%3EOrbit%3C%2Fextra%3E'))%0A_fig.add_trace(go.Scatter(x%3D%5B0%2Cfish_fixed%5B0%5D%5D%2Cy%3D%5B0%2Cfish_fixed%5B1%5D%5D%2Cmode%3D'markers'%2C%0A%20%20%20%20marker%3Ddict(symbol%3D'diamond'%2Csize%3D10%2Ccolor%3Dcolors%5B'dark'%5D)%2Cname%3D'Fixed%20points'))%0A_fig.add_hline(y%3Dmu%2Fbeta%2Cline_color%3Dcolors%5B'slate'%5D%2Cline_dash%3D'dash')%0A_fig.add_vline(x%3Dnu%2Fbeta%2Cline_color%3Dcolors%5B'rust'%5D%2Cline_dash%3D'dash')%0A_fig.add_vline(x%3D0%2Cline_color%3Dcolors%5B'slate'%5D)%0A_fig.add_hline(y%3D0%2Cline_color%3Dcolors%5B'rust'%5D)%0A_fig.update_layout(xaxis_title%3D'Fish%20F'%2Cyaxis_title%3D'Sharks%20S'%2Cdragmode%3D'lasso'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20xaxis_range%3D%5B0%2C_upper%5B0%5D%5D%2Cyaxis_range%3D%5B0%2C_upper%5B1%5D%5D)%0Afish_phase%20%3D%20mo.ui.plotly(style(_fig%2C430)%2Clabel%3D'Select%20orbit%20points%20to%20inspect%20their%20local%20velocity%20and%20Jacobian')%0Amo.vstack(%5Bfish_phase%2Cnote_md('The%20lasso%20selects%20the%20latest%20enclosed%20sample%20for%20the%20local%20calculations%20below%3B%20an%20empty%20selection%20uses%20the%20initial%20state.%20Arrows%20are%20normalized%20to%20show%20direction.%20Blue%20nullclines%20have%20F%CC%87%20%3D%200%3B%20rust%20nullclines%20have%20S%CC%87%20%3D%200.')%5D)
ewan_obsidian_ready%0Afish_selected_ids%20%3D%20sorted(%7Bint(p%5B'customdata'%5D)%20for%20p%20in%20fish_phase.points%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20p.get('curveNumber')%20%3D%3D%200%20and%20p.get('customdata')%20is%20not%20None%7D)%0Afish_inspect_id%20%3D%20fish_selected_ids%5B-1%5D%20if%20fish_selected_ids%20else%200%0Afish_inspect_state%20%3D%20fish_states%5Bfish_inspect_id%5D%0Afish_local_J%20%3D%20fish_jacobian(fish_inspect_state%2Cmu%2Cnu%2Cbeta)%0Afish_local_velocity%20%3D%20fish_rhs(0%2Cfish_inspect_state%2Cmu%2Cnu%2Cbeta)
ewan_obsidian_ready%0Anote_md(rf%22%22%22%0A%23%23%23%20Jacobian%20of%20the%20velocity%20field%0A%0AIn%20coordinates%20%24(F%2CS)%24%2C%20the%20%5B%5BLinearization%20and%20the%20Jacobian%7CJacobian%5D%5D%20is%0A%24%24J(F%2CS)%3D%5Cbegin%7B%7Bpmatrix%7D%7D%0A%5Cpartial_F%5Cdot%20F%20%26%20%5Cpartial_S%5Cdot%20F%5C%5C%0A%5Cpartial_F%5Cdot%20S%20%26%20%5Cpartial_S%5Cdot%20S%0A%5Cend%7B%7Bpmatrix%7D%7D%0A%3D%5Cbegin%7B%7Bpmatrix%7D%7D%5Cmu-%5Cbeta%20S%26-%5Cbeta%20F%5C%5C%5Cbeta%20S%26%5Cbeta%20F-%5Cnu%5Cend%7B%7Bpmatrix%7D%7D.%24%24%0AColumn%20%24j%24%20gives%20the%20velocity%20response%20to%20a%20perturbation%20in%20population%20%24j%24%3B%20row%20%24i%24%20collects%20the%20derivatives%20of%20velocity%20component%20%24i%24.%20In%20particular%2C%20%24%5Cpartial_F%5Cdot%20F%24%20holds%20%24S%24%20constant%2C%20whereas%20%24%5Cddot%20F%24%20follows%20the%20changing%20state%20along%20time.%20At%20the%20selected%20sample%20%24t%3D%7Bfish_time%5Bfish_inspect_id%5D%3A.3f%7D%24%2C%20%24(F%2CS)%3D(%7Bfish_inspect_state%5B0%5D%3A.3f%7D%2C%7Bfish_inspect_state%5B1%5D%3A.3f%7D)%24%2C%0A%24%24f(F%2CS)%3D%5Cbegin%7B%7Bpmatrix%7D%7D%7Bfish_local_velocity%5B0%5D%3A.3f%7D%5C%5C%7Bfish_local_velocity%5B1%5D%3A.3f%7D%5Cend%7B%7Bpmatrix%7D%7D%2C%0A%5Cqquad%20J%3D%5Cbegin%7B%7Bpmatrix%7D%7D%7Bfish_local_J%5B0%2C0%5D%3A.3f%7D%26%7Bfish_local_J%5B0%2C1%5D%3A.3f%7D%5C%5C%0A%7Bfish_local_J%5B1%2C0%5D%3A.3f%7D%26%7Bfish_local_J%5B1%2C1%5D%3A.3f%7D%5Cend%7B%7Bpmatrix%7D%7D.%24%24%0AThe%20Jacobian%20exists%20along%20the%20whole%20orbit%2C%20but%20its%20eigenvalues%20at%20an%20arbitrary%20point%20do%20not%20classify%20the%20orbit.%20At%20a%20fixed%20point%20%24f(x%5E*)%3D0%24%2C%20the%20constant%20term%20disappears%20from%20the%20Taylor%20expansion%3A%0A%24%24f(x%5E*%2B%5Ceta)%3DJ(x%5E*)%5Ceta%2BO(%5C%7C%5Ceta%5C%7C%5E2)%2C%5Cqquad%20%5Cdot%5Ceta%5Capprox%20J(x%5E*)%5Ceta.%24%24%0A%22%22%22)
ewan_obsidian_ready%0Aslice_entry%20%3D%20mo.ui.dropdown(options%3D%7B%0A%20%20%20%20'%E2%88%82F%CC%87%2F%E2%88%82F'%3A(0%2C0)%2C'%E2%88%82F%CC%87%2F%E2%88%82S'%3A(0%2C1)%2C'%E2%88%82S%CC%87%2F%E2%88%82F'%3A(1%2C0)%2C'%E2%88%82S%CC%87%2F%E2%88%82S'%3A(1%2C1)%7D%2C%0A%20%20%20%20value%3D'%E2%88%82F%CC%87%2F%E2%88%82S'%2Clabel%3D'Jacobian%20entry%20to%20inspect')%0Aslice_entry
The selected partial derivative is -0.500, giving the first-order change in Ḟ per unit change in Sharks S. Each equation is affine in either population with the other held fixed, so the slice coincides with its tangent. The bilinear term appears when both populations vary.
ewan_obsidian_ready%0A_row%2C_col%20%3D%20slice_entry.value%0A_names%20%3D%20%5B'Fish%20F'%2C'Sharks%20S'%5D%0A_velocity_names%20%3D%20%5B'F%CC%87'%2C'S%CC%87'%5D%0A_center%20%3D%20fish_inspect_state%5B_col%5D%0A_grid%20%3D%20np.linspace(max(0%2C_center-1)%2C_center%2B1%2C201)%0A_states%20%3D%20np.tile(fish_inspect_state%2C(len(_grid)%2C1))%0A_states%5B%3A%2C_col%5D%3D_grid%0A_values%20%3D%20np.array(%5Bfish_rhs(0%2Cx%2Cmu%2Cnu%2Cbeta)%5B_row%5D%20for%20x%20in%20_states%5D)%0A_tangent%20%3D%20fish_local_velocity%5B_row%5D%2Bfish_local_J%5B_row%2C_col%5D*(_grid-_center)%0A_fig%20%3D%20go.Figure(go.Scatter(x%3D_grid%2Cy%3D_values%2Cname%3D'Exact%20velocity%20slice'%2Cline%3Ddict(color%3Dcolors%5B'pine'%5D%2Cwidth%3D4)))%0A_fig.add_trace(go.Scatter(x%3D_grid%2Cy%3D_tangent%2Cname%3D'Jacobian%20tangent'%2Cline%3Ddict(color%3Dcolors%5B'rust'%5D%2Cdash%3D'dash')))%0A_fig.add_trace(go.Scatter(x%3D%5B_center%5D%2Cy%3D%5Bfish_local_velocity%5B_row%5D%5D%2Cmode%3D'markers'%2Cname%3D'Selected%20state'%2Cmarker%3Ddict(size%3D9%2Ccolor%3Dcolors%5B'dark'%5D)))%0A_fig.update_layout(xaxis_title%3Df'%7B_names%5B_col%5D%7D%20(other%20population%20held%20fixed)'%2Cyaxis_title%3D_velocity_names%5B_row%5D)%0Amo.vstack(%5Bstyle(_fig%2C310)%2Cnote_md(f'The%20selected%20partial%20derivative%20is%20%7Bfish_local_J%5B_row%2C_col%5D%3A.3f%7D%2C%20giving%20the%20first-order%20change%20in%20%7B_velocity_names%5B_row%5D%7D%20per%20unit%20change%20in%20%7B_names%5B_col%5D%7D.%20Each%20equation%20is%20affine%20in%20either%20population%20with%20the%20other%20held%20fixed%2C%20so%20the%20slice%20coincides%20with%20its%20tangent.%20The%20bilinear%20term%20appears%20when%20both%20populations%20vary.')%5D)
State as the orbit parameter
Where F ˙ ≠ 0 \dot F\ne0 F ˙ = 0 ||(\dot F\ne0||) , time can be eliminated locally:
d S d F = d S / d t d F / d t = S ( β F − ν ) F ( μ − β S ) , d t d F = 1 F ˙ .
\frac{dS}{dF}=\frac{dS/dt}{dF/dt}=\frac{S(\beta F-\nu)}{F(\mu-\beta S)},\qquad
\frac{dt}{dF}=\frac{1}{\dot F}.
d F d S = d F / d t d S / d t = F ( μ − βS ) S ( βF − ν ) , d F d t = F ˙ 1 . ||[
\frac{dS}{dF}=\frac{dS/dt}{dF/dt}=\frac{S(\beta F-\nu)}{F(\mu-\beta S)},\qquad
\frac{dt}{dF}=\frac{1}{\dot F}.
||] The ratio d S / d F dS/dF d S / d F ||(dS/dF||) is the slope of the orbit in the phase plane, with both populations changing. The Jacobian entry ∂ S ˙ / ∂ F \partial\dot S/\partial F ∂ S ˙ / ∂ F ||(\partial\dot S/\partial F||) instead measures the response of shark velocity to fish abundance at fixed S S S ||(S||) . At a turning point of F ( t ) F(t) F ( t ) ||(F(t)||) , the orbit may have a vertical tangent and F F F ||(F||) ceases to be a local time coordinate. A nonconstant closed orbit therefore requires more than one branch of S ( F ) S(F) S ( F ) ||(S(F)||) . At selected time 0.00: dS/dF = -0.400 and dt/dF = 2.000.
ewan_obsidian_ready%0A%23%20Reparameterizing%20an%20orbit%20by%20F%20differs%20from%20differentiating%20its%20vector%20field.%0A_orbit_start%3Dmax(0%2Cfish_inspect_id-30)%0A_orbit_end%3Dmin(len(fish_time)%2Cfish_inspect_id%2B31)%0A_orbit%3Dfish_states%5B_orbit_start%3A_orbit_end%5D%0A_speed%3Dnp.linalg.norm(fish_local_velocity)%0A_scale%3Dmax(np.ptp(_orbit%5B%3A%2C0%5D)%2Cnp.ptp(_orbit%5B%3A%2C1%5D)%2C0.1)*0.45%0A_tangent_direction%3Dfish_local_velocity%2F_speed%20if%20_speed%3E1e-12%20else%20np.zeros(2)%0A_tangent%3Dfish_inspect_state%2Bnp.array(%5B-1%2C1%5D)%5B%3A%2CNone%5D*_scale*_tangent_direction%0A_fig%3Dgo.Figure(go.Scatter(x%3D_orbit%5B%3A%2C0%5D%2Cy%3D_orbit%5B%3A%2C1%5D%2Cmode%3D'lines'%2Cname%3D'Orbit%20near%20selected%20time'%2Cline%3Ddict(color%3Dcolors%5B'pine'%5D%2Cwidth%3D3)))%0A_fig.add_trace(go.Scatter(x%3D_tangent%5B%3A%2C0%5D%2Cy%3D_tangent%5B%3A%2C1%5D%2Cmode%3D'lines'%2Cname%3D'Velocity%20tangent'%2Cline%3Ddict(color%3Dcolors%5B'rust'%5D%2Cdash%3D'dash')))%0A_fig.add_trace(go.Scatter(x%3D%5Bfish_inspect_state%5B0%5D%5D%2Cy%3D%5Bfish_inspect_state%5B1%5D%5D%2Cmode%3D'markers'%2Cname%3D'Selected%20point'%2Cmarker%3Ddict(color%3Dcolors%5B'dark'%5D%2Csize%3D9)))%0A_fig.update_layout(xaxis_title%3D'Fish%20F'%2Cyaxis_title%3D'Sharks%20S'%2Cyaxis%3Ddict(scaleanchor%3D'x'%2Cscaleratio%3D1))%0Aif%20abs(fish_local_velocity%5B0%5D)%3E1e-10%3A%0A%20%20%20%20_slope_text%3Df%22dS%2FdF%20%3D%20%7Bfish_local_velocity%5B1%5D%2Ffish_local_velocity%5B0%5D%3A.3f%7D%20and%20dt%2FdF%20%3D%20%7B1%2Ffish_local_velocity%5B0%5D%3A.3f%7D.%22%0Aelif%20_speed%3E1e-10%3A%0A%20%20%20%20_slope_text%3D'Vertical%20tangent%3B%20F%20cannot%20parameterize%20the%20orbit%20locally.'%0Aelse%3A%0A%20%20%20%20_slope_text%3D'Both%20velocities%20vanish%20at%20a%20fixed%20point%2C%20leaving%20the%20orbit%20slope%20undefined%20(0%2F0).'%0Amo.vstack(%5Bnote_md(r%22%22%22%0A%23%23%23%20State%20as%20the%20orbit%20parameter%0A%0AWhere%20%24%5Cdot%20F%5Cne0%24%2C%20time%20can%20be%20eliminated%20locally%3A%0A%24%24%5Cfrac%7BdS%7D%7BdF%7D%3D%5Cfrac%7BdS%2Fdt%7D%7BdF%2Fdt%7D%3D%5Cfrac%7BS(%5Cbeta%20F-%5Cnu)%7D%7BF(%5Cmu-%5Cbeta%20S)%7D%2C%5Cqquad%0A%5Cfrac%7Bdt%7D%7BdF%7D%3D%5Cfrac%7B1%7D%7B%5Cdot%20F%7D.%24%24%0AThe%20ratio%20%24dS%2FdF%24%20is%20the%20slope%20of%20the%20orbit%20in%20the%20phase%20plane%2C%20with%20both%20populations%20changing.%20The%20Jacobian%20entry%20%24%5Cpartial%5Cdot%20S%2F%5Cpartial%20F%24%20instead%20measures%20the%20response%20of%20shark%20velocity%20to%20fish%20abundance%20at%20fixed%20%24S%24.%20At%20a%20turning%20point%20of%20%24F(t)%24%2C%20the%20orbit%20may%20have%20a%20vertical%20tangent%20and%20%24F%24%20ceases%20to%20be%20a%20local%20time%20coordinate.%20A%20nonconstant%20closed%20orbit%20therefore%20requires%20more%20than%20one%20branch%20of%20%24S(F)%24.%0A%22%22%22)%2Cstyle(_fig%2C280)%2Cnote_md(f'At%20selected%20time%20%7Bfish_time%5Bfish_inspect_id%5D%3A.2f%7D%3A%20'%2B_slope_text)%5D)
ewan_obsidian_ready%0Anote_md(rf%22%22%22%0AAt%20extinction%20and%20coexistence%2C%0A%24%24J_0%3D%5Cbegin%7B%7Bpmatrix%7D%7D%5Cmu%260%5C%5C0%26-%5Cnu%5Cend%7B%7Bpmatrix%7D%7D%2C%5Cqquad%0AJ_*%20%3D%5Cbegin%7B%7Bpmatrix%7D%7D0%26-%5Cnu%5C%5C%5Cmu%260%5Cend%7B%7Bpmatrix%7D%7D.%24%24%0AThe%20origin%20has%20eigenvalues%20%24%5Cmu%2C-%5Cnu%24%20and%20determinant%20%24-%5Cmu%5Cnu%3C0%24%2C%20giving%20a%20%5B%5BSaddle%20fixed%20point%7Csaddle%5D%5D.%20Contraction%20along%20one%20eigendirection%20coexists%20with%20expansion%20along%20the%20other.%20At%20coexistence%2C%20%24%5Ctau%3D0%24%2C%20%24%5CDelta%3D%5Cmu%5Cnu%3E0%24%20and%20%24%5Clambda_%5Cpm%3D%5Cpm%20i%5Csqrt%7B%7B%5Cmu%5Cnu%7D%7D%24%2C%20so%20the%20linearized%20system%20is%20a%20center.%20Nonlinear%20stability%20needs%20another%20argument.%20For%20this%20model%2C%0A%24%24H(F%2CS)%3D%5Cbeta(F%2BS)-%5Cnu%5Clog%20F-%5Cmu%5Clog%20S%2C%5Cqquad%20%5Cfrac%7B%7BdH%7D%7D%7B%7Bdt%7D%7D%3D0.%24%24%0AIn%20the%20positive%20quadrant%2C%20the%20level%20curves%20of%20%24H%24%20surround%20its%20strict%20minimum%20at%20coexistence%20and%20form%20closed%20orbits.%20The%20numerical%20drift%20is%20%24%5Cmax%7CH(t)-H(0)%7C%3D%7Bnp.max(np.abs(fish_H-fish_H%5B0%5D))%3A.2e%7D%24.%20A%20center%20is%20surrounded%20by%20a%20family%20of%20closed%20orbits%3B%20a%20stable%20%5B%5BLimit%20Cycle%7Climit%20cycle%5D%5D%20attracts%20nearby%20trajectories%20onto%20an%20isolated%20periodic%20orbit%2C%20while%20a%20stable%20spiral%20converges%20to%20the%20fixed%20point.%0A%22%22%22)
ewan_obsidian_ready%0Anote_md(r%22%22%22%0A%23%23%23%20Evolution%20of%20a%20neighborhood%0A%0AA%20small%20circle%20around%20%24x%5E*%24%20gives%20perturbations%20%24%5Ceta_0%24%20in%20every%20direction.%20The%20Jacobian%20maps%20these%20displacements%20to%20initial%20velocities%2C%20while%20the%20matrix%20exponential%20evolves%20them%20for%20a%20finite%20time%3A%0A%24%24%5Cdot%5Ceta(0)%3DJ_*%5Ceta_0%2C%5Cqquad%20%5Ceta(t)%3De%5E%7BtJ_*%7D%5Ceta_0.%24%24%0AFor%20a%20flow%2C%20%24J_*%5Ceta_0%24%20is%20a%20velocity.%20The%20neighborhood%20at%20time%20%24t%24%20comes%20from%20%24e%5E%7BtJ_*%7D%24%2C%20as%20follows%20from%20the%20linear%20system%20%24%5Cdot%5Ceta%3DJ_*%5Ceta%24.%20The%20nonlinear%20image%20agrees%20to%20first%20order%20as%20the%20initial%20radius%20tends%20to%20zero%20at%20fixed%20time%3B%20over%20longer%20intervals%2C%20neglected%20terms%20can%20accumulate.%20The%20two%20plots%20compare%20these%20velocity%20and%20displacement%20approximations%20separately.%0A%22%22%22)
ewan_obsidian_ready%0Aneighborhood_fixed%20%3D%20mo.ui.dropdown(options%3D%5B'Coexistence%20(center)'%2C'Origin%20(saddle)'%5D%2Cvalue%3D'Coexistence%20(center)'%2Clabel%3D'Fixed%20point')%0Aneighborhood_radius%20%3D%20mo.ui.slider(0.01%2C0.4%2Cstep%3D0.01%2Cvalue%3D0.12%2Clabel%3D'Neighborhood%20radius%20%2F%20min(F*%2C%20S*)'%2Cdebounce%3DTrue)%0Aneighborhood_time%20%3D%20mo.ui.slider(0%2C1.5%2Cstep%3D0.05%2Cvalue%3D0.8%2Clabel%3D'Elapsed%20time'%2Cdebounce%3DTrue)%0Amo.hstack(%5Bneighborhood_fixed%2Cneighborhood_radius%2Cneighborhood_time%5D%2Cwrap%3DTrue)
ewan_obsidian_ready%0Aneighborhood_center%20%3D%20fish_fixed%20if%20neighborhood_fixed.value.startswith('Coexistence')%20else%20np.zeros(2)%0Aneighborhood_J%20%3D%20fish_jacobian(neighborhood_center%2Cmu%2Cnu%2Cbeta)%0Aneighborhood_absolute_radius%20%3D%20neighborhood_radius.value*min(fish_fixed)%0Aneighborhood_angles%20%3D%20np.linspace(0%2C2*np.pi%2C49)%5B%3A-1%5D%0Aneighborhood_eta%20%3D%20neighborhood_absolute_radius*np.column_stack(%5Bnp.cos(neighborhood_angles)%2Cnp.sin(neighborhood_angles)%5D)%0Aneighborhood_initial%20%3D%20neighborhood_center%2Bneighborhood_eta%0A%0Adef%20neighborhood_rhs(t%2Cflat)%3A%0A%20%20%20%20states%20%3D%20flat.reshape(-1%2C2)%0A%20%20%20%20F%2CS%20%3D%20states.T%0A%20%20%20%20return%20np.column_stack(%5BF*(mu-beta*S)%2CS*(beta*F-nu)%5D).ravel()%0A%0Adef%20neighborhood_guard(t%2Cflat)%3A%0A%20%20%20%20return%20100-np.max(np.abs(flat))%0Aneighborhood_guard.terminal%20%3D%20True%0Aneighborhood_solution%20%3D%20solve_ivp(neighborhood_rhs%2C(0%2C1.5)%2Cneighborhood_initial.ravel()%2C%0A%20%20%20%20method%3D'DOP853'%2Crtol%3D1e-10%2Catol%3D1e-12%2Cdense_output%3DTrue%2Cevents%3Dneighborhood_guard%2Cmax_step%3D0.05)
At t = 0.80, RMS nonlinear–linear displacement error = 0.00498 (radius 0.168). At coexistence, the linear motion has angular frequency √(μν). Circular neighborhoods generally deform because J need not be a pure rotation in population coordinates. The linear flow changes area by det ( e t J ) = e t tr J \det(e^{tJ})=e^{t\operatorname{tr}J} det ( e t J ) = e t tr J ||(\det(e^{tJ})=e^{t\operatorname{tr}J}||) . Zero trace at the center gives area preservation, though individual directions can stretch or contract. This instantaneous, direction-dependent growth is described by the Local Lyapunov Exponent .
ewan_obsidian_ready%0A_nt%20%3D%20min(neighborhood_time.value%2Cfloat(neighborhood_solution.t%5B-1%5D))%0Aneighborhood_linear%20%3D%20(expm(_nt*neighborhood_J)%40neighborhood_eta.T).T%0Aneighborhood_nonlinear%20%3D%20neighborhood_solution.sol(_nt).reshape(-1%2C2)-neighborhood_center%0Aneighborhood_velocity%20%3D%20(neighborhood_J%40neighborhood_eta.T).T%0Aneighborhood_exact_velocity%20%3D%20neighborhood_rhs(0%2Cneighborhood_initial.ravel()).reshape(-1%2C2)%0Aneighborhood_error%20%3D%20float(np.sqrt(np.mean(np.sum((neighborhood_linear-neighborhood_nonlinear)**2%2Caxis%3D1))))%0A_fig%20%3D%20make_subplots(rows%3D1%2Ccols%3D2%2Csubplot_titles%3D('Initial%20displacement%20%E2%86%92%20velocity'%2C'Displacement%20after%20elapsed%20time'))%0Afor%20_points%2C_label%2C_color%2C_dash%2C_col%20in%20%5B%0A%20%20%20%20(neighborhood_velocity%2C'J%CE%B7%E2%82%80'%2Ccolors%5B'rust'%5D%2C'dash'%2C1)%2C%0A%20%20%20%20(neighborhood_exact_velocity%2C'f(x*%20%2B%20%CE%B7%E2%82%80)'%2Ccolors%5B'pine'%5D%2C'solid'%2C1)%2C%0A%20%20%20%20(neighborhood_eta%2C'Initial%20circle'%2Ccolors%5B'gray'%5D%2C'dot'%2C2)%2C%0A%20%20%20%20(neighborhood_linear%2C'exp(tJ)%20%CE%B7%E2%82%80'%2Ccolors%5B'rust'%5D%2C'dash'%2C2)%2C%0A%20%20%20%20(neighborhood_nonlinear%2C'Nonlinear%20displacement'%2Ccolors%5B'pine'%5D%2C'solid'%2C2)%5D%3A%0A%20%20%20%20_closed%3Dnp.vstack(%5B_points%2C_points%5B0%5D%5D)%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D_closed%5B%3A%2C0%5D%2Cy%3D_closed%5B%3A%2C1%5D%2Cmode%3D'lines'%2Cname%3D_label%2C%0A%20%20%20%20%20%20%20%20line%3Ddict(color%3D_color%2Cdash%3D_dash%2Cwidth%3D2))%2C1%2C_col)%0A%23%20Matched%20angular%20markers%20show%20where%20each%20initial%20direction%20travels.%0Afor%20_points%2C_col%20in%20%5B(neighborhood_exact_velocity%2C1)%2C(neighborhood_nonlinear%2C2)%5D%3A%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D_points%5B%3A%3A6%2C0%5D%2Cy%3D_points%5B%3A%3A6%2C1%5D%2Cmode%3D'markers'%2Cshowlegend%3DFalse%2C%0A%20%20%20%20%20%20%20%20marker%3Ddict(size%3D6%2Ccolor%3Dneighborhood_angles%5B%3A%3A6%5D%2Ccolorscale%3D'Viridis'))%2C1%2C_col)%0A_fig.update_xaxes(title_text%3D'Velocity%20change%20in%20F'%2Crow%3D1%2Ccol%3D1)%0A_fig.update_yaxes(title_text%3D'Velocity%20change%20in%20S'%2Crow%3D1%2Ccol%3D1)%0A_fig.update_xaxes(title_text%3D'Displacement%20in%20F'%2Crow%3D1%2Ccol%3D2)%0A_fig.update_yaxes(title_text%3D'Displacement%20in%20S'%2Crow%3D1%2Ccol%3D2)%0A_fig.update_yaxes(scaleanchor%3D'x'%2Cscaleratio%3D1%2Crow%3D1%2Ccol%3D1)%0A_fig.update_yaxes(scaleanchor%3D'x2'%2Cscaleratio%3D1%2Crow%3D1%2Ccol%3D2)%0A_extra%20%3D%20('%20At%20the%20saddle%2C%20the%20full%20neighborhood%20extends%20into%20negative%20populations%3B%20its%20biological%20part%20lies%20in%20the%20nonnegative%20quadrant.%20The%20F%20axis%20is%20unstable%20and%20the%20S%20axis%20stable%2C%20giving%20the%20eigendirections%20of%20the%20%5B%5BStable%20and%20Unstable%20Manifolds%5D%5D.'%20if%20neighborhood_fixed.value.startswith('Origin')%20else%20'%20At%20coexistence%2C%20the%20linear%20motion%20has%20angular%20frequency%20%E2%88%9A(%CE%BC%CE%BD).%20Circular%20neighborhoods%20generally%20deform%20because%20J%20need%20not%20be%20a%20pure%20rotation%20in%20population%20coordinates.')%0Aif%20_nt%3Cneighborhood_time.value%20or%20not%20neighborhood_solution.success%3A%0A%20%20%20%20_extra%2B%3D'%20Integration%20stopped%20early%20at%20the%20neighborhood%20excursion%20guard%20or%20solver%20failure%3B%20the%20displayed%20time%20is%20truncated.'%0Amo.vstack(%5Bstyle(_fig%2C380)%2Cnote_md(f'At%20t%20%3D%20%7B_nt%3A.2f%7D%2C%20RMS%20nonlinear%E2%80%93linear%20displacement%20error%20%3D%20%7Bneighborhood_error%3A.3g%7D%20(radius%20%7Bneighborhood_absolute_radius%3A.3g%7D).'%2B_extra)%2C%0A%20%20%20%20note_md(r'The%20linear%20flow%20changes%20area%20by%20%24%5Cdet(e%5E%7BtJ%7D)%3De%5E%7Bt%5Coperatorname%7Btr%7DJ%7D%24.%20Zero%20trace%20at%20the%20center%20gives%20area%20preservation%2C%20though%20individual%20directions%20can%20stretch%20or%20contract.%20This%20instantaneous%2C%20direction-dependent%20growth%20is%20described%20by%20the%20%5B%5BLocal%20Lyapunov%20Exponent%5D%5D.')%5D)
ewan_obsidian_ready%0Anote_md(r%22%22%22%0A%23%23%23%20Trace%20and%20determinant%0A%0AFor%20a%20real%20%242%5Ctimes2%24%20matrix%2C%0A%24%24%5Ctau%3D%5Coperatorname%7Btr%7DJ%3DJ_%7B11%7D%2BJ_%7B22%7D%2C%5Cqquad%0A%5CDelta%3D%5Cdet%20J%3DJ_%7B11%7DJ_%7B22%7D-J_%7B12%7DJ_%7B21%7D%2C%5Cqquad%0A%5Clambda_%5Cpm%3D%5Cfrac%7B%5Ctau%5Cpm%5Csqrt%7B%5Ctau%5E2-4%5CDelta%7D%7D%7B2%7D.%24%24%0AIf%20%24%5CDelta%3C0%24%2C%20the%20eigenvalues%20are%20real%20with%20opposite%20signs%2C%20giving%20a%20saddle%20regardless%20of%20trace.%20With%20%24%5CDelta%3E0%24%2C%20negative%20trace%20gives%20asymptotic%20stability%20and%20positive%20trace%20gives%20instability.%20The%20discriminant%20separates%20nodes%20(%24%5Ctau%5E2-4%5CDelta%3E0%24)%20from%20spirals%20(%24%5Ctau%5E2-4%5CDelta%3C0%24%2C%20%24%5Ctau%5Cne0%24)%3B%20at%20%24%5Ctau%3D0%24%2C%20%24%5CDelta%3E0%24%2C%20the%20linear%20system%20is%20a%20center.%20On%20%24%5Ctau%5E2%3D4%5CDelta%24%2C%20eigenvalues%20repeat%20and%20the%20eigenspace%20determines%20the%20geometry.%20Negative%20trace%20alone%20is%20insufficient%3A%20contraction%20in%20one%20direction%20can%20outweigh%20expansion%20in%20another%20while%20the%20equilibrium%20remains%20unstable.%0A%0AFor%20a%20nonlinear%20system%2C%20%24%5CDelta%3D0%24%20or%20%24%5Ctau%3D0%2C%5CDelta%3E0%24%20leaves%20a%20nonhyperbolic%20equilibrium%2C%20so%20linearization%20alone%20is%20inconclusive.%20These%20trace%E2%80%93determinant%20conditions%20apply%20to%20two%20dimensions.%0A%22%22%22)
ewan_obsidian_ready%0Alinear_inputs%20%3D%20tangle(r%22%5Ctau%3D%5Ctangle%7Btau%7D%2C%5Cqquad%5CDelta%3D%5Ctangle%7Bdelta%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dict(tau%3Dparameter(-0.8%2C-3%2C3)%2Cdelta%3Dparameter(1%2C-2%2C3)))%0Alinear_inputs
A selected point sets (τ, Δ); multiple selected points use their mean. An empty selection uses the formula values above.
ewan_obsidian_ready%0A_tau%2C%20_delta%20%3D%20np.meshgrid(np.arange(-3%2C3.01%2C0.2)%2Cnp.arange(-2%2C3.01%2C0.2))%0A_fig%20%3D%20go.Figure(go.Scatter(x%3D_tau.ravel()%2Cy%3D_delta.ravel()%2Cmode%3D'markers'%2C%0A%20%20%20%20marker%3Ddict(size%3D7%2Ccolor%3Dcolors%5B'pine'%5D%2Copacity%3D0.55)%2Cname%3D'Choose%20a%20system'%2C%0A%20%20%20%20hovertemplate%3D'%CF%84%3D%25%7Bx%3A.1f%7D%3Cbr%3E%CE%94%3D%25%7By%3A.1f%7D%3Cextra%3E%3C%2Fextra%3E'))%0A_x%20%3D%20np.linspace(-3%2C3%2C201)%0A_fig.add_trace(go.Scatter(x%3D_x%2Cy%3D_x**2%2F4%2Cmode%3D'lines'%2Cline%3Ddict(color%3Dcolors%5B'rust'%5D)%2Cname%3D'%CE%94%20%3D%20%CF%84%C2%B2%20%2F%204'))%0A_fig.add_hline(y%3D0%2Cline_color%3Dcolors%5B'dark'%5D)%0A_fig.add_vline(x%3D0%2Cline_color%3Dcolors%5B'dark'%5D)%0Afor%20_x%2C_y%2C_label%20in%20%5B(-1.5%2C-1%2C'Saddles')%2C(-1.8%2C2%2C'Stable%20spirals')%2C(1.8%2C2%2C'Unstable%20spirals')%2C(-2.2%2C0.35%2C'Stable%20nodes')%2C(2.2%2C0.35%2C'Unstable%20nodes')%5D%3A%0A%20%20%20%20_fig.add_annotation(x%3D_x%2Cy%3D_y%2Ctext%3D_label%2Cshowarrow%3DFalse)%0A_fig.update_layout(xaxis_title%3D'Trace%20%CF%84'%2Cyaxis_title%3D'Determinant%20%CE%94'%2Cdragmode%3D'select'%2Cclickmode%3D'event%2Bselect')%0Atrace_map%20%3D%20mo.ui.plotly(style(_fig%2C390)%2Clabel%3D'Select%20trace%20and%20determinant')%0Amo.vstack(%5Btrace_map%2Cnote_md('A%20selected%20point%20sets%20(%CF%84%2C%20%CE%94)%3B%20multiple%20selected%20points%20use%20their%20mean.%20An%20empty%20selection%20uses%20the%20formula%20values%20above.')%5D)
ewan_obsidian_ready%0A_trace_points%20%3D%20%5Bp%20for%20p%20in%20trace_map.points%20if%20p.get('curveNumber')%20%3D%3D%200%5D%0Alinear_tau%20%3D%20float(np.mean(%5Bp%5B'x'%5D%20for%20p%20in%20_trace_points%5D))%20if%20_trace_points%20else%20linear_inputs.values%5B'tau'%5D%0Alinear_delta%20%3D%20float(np.mean(%5Bp%5B'y'%5D%20for%20p%20in%20_trace_points%5D))%20if%20_trace_points%20else%20linear_inputs.values%5B'delta'%5D%0A%23%20One%20representative%20with%20the%20chosen%20trace%20and%20determinant%2C%20not%20a%20unique%20matrix.%0Alinear_J%20%3D%20np.array(%5B%5B0.%2C1.%5D%2C%5B-linear_delta%2Clinear_tau%5D%5D)%0Alinear_eigenvalues%20%3D%20np.linalg.eigvals(linear_J)%0Alinear_discriminant%20%3D%20linear_tau**2-4*linear_delta%0Aif%20linear_delta%20%3C%20-1e-8%3A%0A%20%20%20%20linear_class%20%3D%20'Saddle%20(unstable)'%0Aelif%20abs(linear_delta)%3C1e-8%3A%0A%20%20%20%20linear_class%20%3D%20'Zero%20eigenvalue%3A%20degenerate%20boundary'%0Aelif%20abs(linear_tau)%3C1e-8%3A%0A%20%20%20%20linear_class%20%3D%20'Linear%20center%3B%20nonlinear%20classification%20needs%20more%20evidence'%0Aelse%3A%0A%20%20%20%20_stability%20%3D%20'Stable'%20if%20linear_tau%3C0%20else%20'Unstable'%0A%20%20%20%20_kind%20%3D%20'spiral'%20if%20linear_discriminant%20%3C%20-1e-8%20else%20('node'%20if%20linear_discriminant%3E1e-8%20else%20'repeated-eigenvalue%20node')%0A%20%20%20%20linear_class%20%3D%20f'%7B_stability%7D%20%7B_kind%7D'%0Alinear_time%20%3D%20np.linspace(0%2C8%2C250)%0Alinear_propagators%20%3D%20np.array(%5Bexpm(linear_J*t)%20for%20t%20in%20linear_time%5D)
ewan_obsidian_ready%0A_fig%20%3D%20go.Figure()%0Afor%20_theta%20in%20np.linspace(0%2C2*np.pi%2C9)%5B%3A-1%5D%3A%0A%20%20%20%20_start%20%3D%200.7*np.array(%5Bnp.cos(_theta)%2Cnp.sin(_theta)%5D)%0A%20%20%20%20_orbit%20%3D%20linear_propagators%40_start%0A%20%20%20%20%23%20Clip%20only%20the%20displayed%20segment%20when%20it%20leaves%20the%20local%20plotting%20neighborhood.%0A%20%20%20%20_outside%20%3D%20np.flatnonzero(np.max(np.abs(_orbit)%2Caxis%3D1)%3E3)%0A%20%20%20%20if%20len(_outside)%3A%20_orbit%20%3D%20_orbit%5B%3A_outside%5B0%5D%2B1%5D%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D_orbit%5B%3A%2C0%5D%2Cy%3D_orbit%5B%3A%2C1%5D%2Cmode%3D'lines'%2Cshowlegend%3DFalse%2Cline%3Ddict(width%3D1.5)))%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D%5B_start%5B0%5D%5D%2Cy%3D%5B_start%5B1%5D%5D%2Cmode%3D'markers'%2Cshowlegend%3DFalse%2Cmarker%3Ddict(size%3D4%2Ccolor%3Dcolors%5B'dark'%5D)))%0A_fig.update_layout(xaxis_title%3D'Displacement%20%CE%B7%E2%82%81'%2Cyaxis_title%3D'Displacement%20%CE%B7%E2%82%82'%2Cxaxis_range%3D%5B-3%2C3%5D%2Cyaxis_range%3D%5B-3%2C3%5D)%0A_eigs%20%3D%20'%2C%20'.join(f'%7Bv.real%3A.3f%7D%7Bv.imag%3A%2B.3f%7Di'%20for%20v%20in%20linear_eigenvalues)%0Amo.vstack(%5Bnote_md(f'**%7Blinear_class%7D**%20%C2%B7%20%CF%84%20%3D%20%7Blinear_tau%3A.2f%7D%2C%20%CE%94%20%3D%20%7Blinear_delta%3A.2f%7D%2C%20%CF%84%C2%B2%20%E2%88%92%204%CE%94%20%3D%20%7Blinear_discriminant%3A.2f%7D.%20Eigenvalues%3A%20%7B_eigs%7D.')%2C%0A%20%20%20%20style(_fig)%2Cnote_md(r'The%20representative%20system%20is%20%24%5Cdot%5Ceta%3D%5Cbegin%7Bpmatrix%7D0%261%5C%5C-%5CDelta%26%5Ctau%5Cend%7Bpmatrix%7D%5Ceta%24%2C%20integrated%20forward%20from%20the%20marked%20initial%20states%20for%208%20time%20units.%20Curves%20are%20truncated%20at%20the%20plotting%20boundary.%20Trace%20and%20determinant%20fix%20the%20eigenvalues%2C%20while%20orientation%20and%20transient%20growth%20also%20depend%20on%20the%20matrix%20entries.')%5D)
ewan_obsidian_ready%0Amultiplier_step%20%3D%20mo.ui.slider(0.05%2C3%2Cstep%3D0.05%2Cvalue%3D0.5%2Clabel%3D'Sampling%20%2F%20Euler%20step%20h'%2Cdebounce%3DTrue)%0Amultiplier_step
At h = 0.50 h=0.50 h = 0.50 ||(h=0.50||) , the largest multiplier magnitude is 0.819 for the exact flow and 0.922 for Euler. The unit-disk criterion from Sinks, Sources, and Saddles applies to these sampled maps. For a center, λ = ± i ω \lambda=\pm i\omega λ = ± iω ||(\lambda=\pm i\omega||) gives
∣ 1 + i h ω ∣ = 1 + h 2 ω 2 > 1 ,
|1+ih\omega|=\sqrt{1+h^2\omega^2}>1,
∣1 + ihω ∣ = 1 + h 2 ω 2 > 1 , ||[
|1+ih\omega|=\sqrt{1+h^2\omega^2}>1,
||] so forward Euler produces an outward spiral for every h > 0 h>0 h > 0 ||(h>0||) , even though the exact linear flow has closed orbits. For λ = α ± i ω \lambda=\alpha\pm i\omega λ = α ± iω ||(\lambda=\alpha\pm i\omega||) , α \alpha α ||(\alpha||) determines asymptotic linear growth and ∣ ω ∣ |\omega| ∣ ω ∣ ||(|\omega|||) gives angular frequency. A crossing of the imaginary axis is part of an Andronov Hopf Bifurcation , but the existence and stability of an emerging limit cycle also depend on nonlinear terms and nondegeneracy conditions.
ewan_obsidian_ready%0A_h%20%3D%20multiplier_step.value%0Aflow_multipliers%20%3D%20np.exp(_h*linear_eigenvalues)%0Aeuler_multipliers%20%3D%201%2B_h*linear_eigenvalues%0A_fig%20%3D%20make_subplots(rows%3D1%2Ccols%3D2%2Csubplot_titles%3D('Flow%20eigenvalues%3A%20left%20half-plane%20is%20stable'%2C'Map%20multipliers%3A%20unit%20disk%20is%20stable'))%0A_fig.add_trace(go.Scatter(x%3Dlinear_eigenvalues.real%2Cy%3Dlinear_eigenvalues.imag%2Cmode%3D'markers'%2Cname%3D'%CE%BB(J)'%2Cmarker%3Ddict(size%3D11%2Ccolor%3Dcolors%5B'pine'%5D))%2C1%2C1)%0A_fig.add_vline(x%3D0%2Cline_dash%3D'dash'%2Crow%3D1%2Ccol%3D1)%0A_theta%3Dnp.linspace(0%2C2*np.pi%2C200)%0A_fig.add_trace(go.Scatter(x%3Dnp.cos(_theta)%2Cy%3Dnp.sin(_theta)%2Cmode%3D'lines'%2Cname%3D'Unit%20circle'%2Cline%3Ddict(color%3Dcolors%5B'gray'%5D))%2C1%2C2)%0Afor%20_z%2C_name%2C_color%2C_symbol%20in%20%5B(flow_multipliers%2C'exp(h%CE%BB)%3A%20exact%20flow'%2Ccolors%5B'pine'%5D%2C'circle')%2C(euler_multipliers%2C'1%20%2B%20h%CE%BB%3A%20Euler'%2Ccolors%5B'rust'%5D%2C'x')%5D%3A%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D_z.real%2Cy%3D_z.imag%2Cmode%3D'markers'%2Cname%3D_name%2Cmarker%3Ddict(size%3D10%2Ccolor%3D_color%2Csymbol%3D_symbol))%2C1%2C2)%0A_fig.update_xaxes(title_text%3D'Real%20part'%2Crow%3D1%2Ccol%3D1)%0A_fig.update_yaxes(title_text%3D'Imaginary%20part'%2Crow%3D1%2Ccol%3D1)%0A_fig.update_xaxes(title_text%3D'Real%20part'%2Crow%3D1%2Ccol%3D2)%0A_fig.update_yaxes(title_text%3D'Imaginary%20part'%2Cscaleanchor%3D'x2'%2Cscaleratio%3D1%2Crow%3D1%2Ccol%3D2)%0Amo.vstack(%5Bstyle(_fig%2C340)%2Cnote_md(rf%22%22%22%0AAt%20%24h%3D%7B_h%3A.2f%7D%24%2C%20the%20largest%20multiplier%20magnitude%20is%20%7Bnp.max(np.abs(flow_multipliers))%3A.3f%7D%20for%20the%20exact%20flow%20and%20%7Bnp.max(np.abs(euler_multipliers))%3A.3f%7D%20for%20Euler.%20The%20unit-disk%20criterion%20from%20%5B%5BSinks%2C%20Sources%2C%20and%20Saddles%5D%5D%20applies%20to%20these%20sampled%20maps.%20For%20a%20center%2C%20%24%5Clambda%3D%5Cpm%20i%5Comega%24%20gives%0A%24%24%7C1%2Bih%5Comega%7C%3D%5Csqrt%7B%7B1%2Bh%5E2%5Comega%5E2%7D%7D%3E1%2C%24%24%0Aso%20forward%20Euler%20produces%20an%20outward%20spiral%20for%20every%20%24h%3E0%24%2C%20even%20though%20the%20exact%20linear%20flow%20has%20closed%20orbits.%20For%20%24%5Clambda%3D%5Calpha%5Cpm%20i%5Comega%24%2C%20%24%5Calpha%24%20determines%20asymptotic%20linear%20growth%20and%20%24%7C%5Comega%7C%24%20gives%20angular%20frequency.%20A%20crossing%20of%20the%20imaginary%20axis%20is%20part%20of%20an%20%5B%5BAndronov%20Hopf%20Bifurcation%5D%5D%2C%20but%20the%20existence%20and%20stability%20of%20an%20emerging%20limit%20cycle%20also%20depend%20on%20nonlinear%20terms%20and%20nondegeneracy%20conditions.%0A%22%22%22)%5D)
ewan_obsidian_ready%0Anote_md(r%22%22%22%0A%23%23%23%20Generalized%20Lotka%E2%80%93Volterra%0A%0AThe%20three-species%20model%20is%0A%24%24%5Cdot%20x_i%3Dx_i%5Csum_%7Bj%3D1%7D%5E%7B3%7DA_%7Bij%7D(1-x_j)%2C%5Cqquad%0AA%3D%5Cbegin%7Bpmatrix%7D0.5%260.5%260.1%5C%5C-0.5%26-0.1%260.1%5C%5Ca%260.1%260.1%5Cend%7Bpmatrix%7D.%24%24%0ARow%20%24i%24%20corresponds%20to%20the%20affected%20population%20and%20column%20%24j%24%20to%20the%20influencing%20population.%20For%20%24i%5Cne%20j%24%2C%20%24%5Cpartial%5Cdot%20x_i%2F%5Cpartial%20x_j%3D-x_iA_%7Bij%7D%24%2C%20so%20positive%20entries%20inhibit%20growth%20and%20negative%20entries%20promote%20it%20at%20fixed%20%24x_i%3E0%24.%20Thus%20%24A_%7B21%7D%3D-0.5%24%20describes%20the%20positive%20effect%20of%20species%201%20on%20species%202%2C%20while%20%24A_%7B12%7D%3D0.5%24%20describes%20the%20negative%20effect%20of%20species%202%20on%20species%201.%20The%20parameter%20%24a%3DA_%7B31%7D%24%20controls%20the%20effect%20of%20species%201%20on%20species%203.%0A%0AExpansion%20gives%20%24%5Cdot%20x_i%3Dx_i(r_i-%5Csum_jA_%7Bij%7Dx_j)%24%20with%20%24r%3DA%5Cmathbf1%3D(1.1%2C-0.5%2Ca%2B0.2)%5ET%24.%20Intrinsic%20growth%20therefore%20depends%20on%20the%20row%20sum%3B%20changing%20%24a%24%20changes%20both%20%24r_3%24%20and%20an%20interaction%20coefficient.%20The%20abundance%20%24x_i%3D1%24%20is%20a%20reference%20value%2C%20not%20a%20hard%20upper%20bound.%20The%20simulations%20compare%20initial%20states%20%24x_0%24%20and%20%24x_0%2B%5Cvarepsilon(1%2C1%2C-1)%24.%0A%22%22%22)
Lecture parameter values: a = 0.7, 1.2, 1.3 and 1.32; the Colab default is 1.5. Their observed trajectories depend on the initial state, transient and integration interval.
ewan_obsidian_ready%0Aglv_inputs%20%3D%20tangle(%0A%20%20%20%20r%22a%3D%5Ctangle%7Ba%7D%2C%5Cquad%5Cvarepsilon%3D%5Ctangle%7Bepsilon%7D%2C%5Cqquad%20x_1(0)%3D%5Ctangle%7Bx1%7D%2C%5C%20x_2(0)%3D%5Ctangle%7Bx2%7D%2C%5C%20x_3(0)%3D%5Ctangle%7Bx3%7D%22%2C%0A%20%20%20%20dict(a%3Dparameter(1.5%2C-5%2C5%2C0.01)%2Cepsilon%3Dparameter(0.01%2C0%2C0.09%2C0.001%2C3)%2C%0A%20%20%20%20%20%20%20%20%20x1%3Dparameter(0.5%2C0.1%2C2)%2Cx2%3Dparameter(0.5%2C0.1%2C2)%2Cx3%3Dparameter(0.5%2C0.1%2C2)))%0Aglv_horizon%20%3D%20mo.ui.slider(50%2C500%2Cstep%3D50%2Cvalue%3D200%2Clabel%3D'Time%20horizon'%2Cdebounce%3DTrue)%0Amo.vstack(%5Bglv_inputs%2Cglv_horizon%2C%0A%20%20%20%20note_md('Lecture%20parameter%20values%3A%20a%20%3D%200.7%2C%201.2%2C%201.3%20and%201.32%3B%20the%20Colab%20default%20is%201.5.%20Their%20observed%20trajectories%20depend%20on%20the%20initial%20state%2C%20transient%20and%20integration%20interval.')%5D)
ewan_obsidian_ready%0Adef%20interaction_matrix(a)%3A%0A%20%20%20%20return%20np.array(%5B%5B0.5%2C0.5%2C0.1%5D%2C%5B-0.5%2C-0.1%2C0.1%5D%2C%5Ba%2C0.1%2C0.1%5D%5D)%0A%0Adef%20glv_rhs(t%2C%20x%2C%20A)%3A%0A%20%20%20%20return%20x*(A%40(1-x))%0A%0Adef%20glv_jacobian(x%2CA)%3A%0A%20%20%20%20return%20np.diag(A%40(1-x))-np.diag(x)%40A%0A%0Adef%20integrate_glv(A%2Cx0%2CT%2Crtol%3D1e-9%2Catol%3D1e-11)%3A%0A%20%20%20%20%23%20Signed%20states%20are%20retained.%20Stop%20large%20excursions%20rather%20than%20hiding%20them%20with%20abs%2Fclipping.%0A%20%20%20%20def%20excursion(t%2Cx)%3A%0A%20%20%20%20%20%20%20%20return%201e3-np.max(np.abs(x))%0A%20%20%20%20excursion.terminal%20%3D%20True%0A%20%20%20%20excursion.direction%20%3D%20-1%0A%20%20%20%20return%20solve_ivp(%0A%20%20%20%20%20%20%20%20lambda%20t%2Cx%3Aglv_rhs(t%2Cx%2CA)%2C(0%2Cfloat(T))%2Cnp.asarray(x0%2Cdtype%3Dfloat)%2C%0A%20%20%20%20%20%20%20%20method%3D'DOP853'%2Crtol%3Drtol%2Catol%3Datol%2Cdense_output%3DTrue%2Cevents%3Dexcursion)%0A%0Adef%20forward_euler(A%2Cx0%2CT%2Ch)%3A%0A%20%20%20%20steps%20%3D%20int(np.ceil(T%2Fh))%0A%20%20%20%20dt%20%3D%20T%2Fsteps%0A%20%20%20%20%23%20Store%20at%20most%20~5001%20displayed%20samples%3B%20every%20Euler%20step%20is%20still%20calculated.%0A%20%20%20%20stride%20%3D%20max(1%2Cint(np.ceil(steps%2F5000)))%0A%20%20%20%20times%2C%20states%20%3D%20%5B0.%5D%2C%20%5Bnp.asarray(x0%2Cdtype%3Dfloat).copy()%5D%0A%20%20%20%20x%20%3D%20states%5B0%5D.copy()%0A%20%20%20%20status%20%3D%20'complete'%0A%20%20%20%20for%20n%20in%20range(steps)%3A%0A%20%20%20%20%20%20%20%20x%20%3D%20x%2Bdt*glv_rhs(n*dt%2Cx%2CA)%0A%20%20%20%20%20%20%20%20if%20not%20np.all(np.isfinite(x))%20or%20np.max(np.abs(x))%3E1e3%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20status%20%3D%20'stopped%20at%20nonfinite%20state%20or%20%7Cx%7C%20%3E%201000'%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20if%20(n%2B1)%25stride%20%3D%3D%200%20or%20n%3D%3Dsteps-1%20or%20np.any(x%3C0)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20times.append((n%2B1)*dt)%3B%20states.append(x.copy())%0A%20%20%20%20%20%20%20%20if%20np.any(x%3C0)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20status%20%3D%20'stopped%20at%20first%20negative%20abundance%3B%20decrease%20h'%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20return%20np.asarray(times)%2Cnp.asarray(states)%2Cstatus%2Cdt
ewan_obsidian_ready%0Aglv_parameters%20%3D%20dict(glv_inputs.values)%0Aglv_a%20%3D%20float(glv_parameters%5B'a'%5D)%0Aglv_A%20%3D%20interaction_matrix(glv_a)%0Aglv_x0%20%3D%20np.array(%5Bglv_parameters%5Bk%5D%20for%20k%20in%20('x1'%2C'x2'%2C'x3')%5D)%0Aglv_epsilon%20%3D%20float(glv_parameters%5B'epsilon'%5D)%0Aglv_x0_near%20%3D%20glv_x0%2Bglv_epsilon*np.array(%5B1%2C1%2C-1%5D)%0Aglv_base%20%3D%20integrate_glv(glv_A%2Cglv_x0%2Cglv_horizon.value)%0Aglv_near%20%3D%20integrate_glv(glv_A%2Cglv_x0_near%2Cglv_horizon.value)%0Aglv_end%20%3D%20min(glv_base.t%5B-1%5D%2Cglv_near.t%5B-1%5D)%0Aglv_time%20%3D%20np.linspace(0%2Cglv_end%2C4001)%0Aglv_states%20%3D%20glv_base.sol(glv_time).T%0Aglv_states_near%20%3D%20glv_near.sol(glv_time).T%0Aglv_separation%20%3D%20np.linalg.norm(glv_states_near-glv_states%2Caxis%3D1)%0Aglv_eigenvalues%20%3D%20np.linalg.eigvals(-glv_A)
ewan_obsidian_ready%0A_max_real%20%3D%20float(np.max(glv_eigenvalues.real))%0A_local%20%3D%20'locally%20asymptotically%20stable'%20if%20_max_real%20%3C%20-1e-8%20else%20('unstable'%20if%20_max_real%3E1e-8%20else%20'nonhyperbolic%3A%20linearization%20is%20inconclusive')%0A_eigs%20%3D%20'%2C%20'.join(f'%7Bz.real%3A.4f%7D%7Bz.imag%3A%2B.4f%7Di'%20for%20z%20in%20glv_eigenvalues)%0Anote_md(rf%22%22%22%0AThe%20reference%20state%20%24x%5E*%3D(1%2C1%2C1)%24%20is%20a%20fixed%20point%20for%20every%20%24a%24%2C%20since%0A%24%24J(x)%3D%5Coperatorname%7B%7Bdiag%7D%7D(A(%5Cmathbf1-x))-%5Coperatorname%7B%7Bdiag%7D%7D(x)A%2C%0A%5Cqquad%20J(x%5E*)%3D-A.%24%24%0AThe%20eigenvalues%20are%20%7B_eigs%7D%3B%20the%20reference%20equilibrium%20is%20%7B_local%7D.%20This%20classifies%20local%20stability%20at%20%24x%5E*%24%3B%20the%20long-run%20trajectory%20may%20approach%20another%20invariant%20set.%20In%20three%20dimensions%20the%20full%20spectrum%20is%20needed%2C%20beyond%20the%20two-dimensional%20trace%E2%80%93determinant%20diagram.%0A%22%22%22)
ewan_obsidian_ready%0A_fig%20%3D%20go.Figure()%0Afor%20_i%2C_name%20in%20enumerate(%5B'x%E2%82%81'%2C'x%E2%82%82'%2C'x%E2%82%83'%5D)%3A%0A%20%20%20%20for%20_states%2C_dash%2C_suffix%20in%20%5B(glv_states%2C'solid'%2C'base')%2C(glv_states_near%2C'dash'%2C'nearby')%5D%3A%0A%20%20%20%20%20%20%20%20_fig.add_trace(go.Scatter(x%3Dglv_time%2Cy%3D_states%5B%3A%2C_i%5D%2Cmode%3D'lines'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20line%3Ddict(color%3Dspecies_colors%5B_i%5D%2Cdash%3D_dash%2Cwidth%3D1.4)%2Cname%3Df'%7B_name%7D%20%7B_suffix%7D'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20customdata%3Dnp.arange(len(glv_time))))%0A_fig.update_layout(xaxis_title%3D'Time'%2Cyaxis_title%3D'Abundance%20x%E1%B5%A2%20(signed)'%2Cdragmode%3D'select'%2Cselectdirection%3D'h')%0Aglv_time_plot%20%3D%20mo.ui.plotly(style(_fig%2C430)%2Clabel%3D'Select%20a%20time%20interval%20for%20phase%20portrait%2C%20separation%20and%20peaks')%0A_warnings%3D%5B%5D%0Aif%20not%20glv_base.success%20or%20not%20glv_near.success%3A%0A%20%20%20%20_warnings.append('Integration%20failed%3A%20'%2Bglv_base.message%2B'%20%2F%20'%2Bglv_near.message)%0Aif%20glv_end%20%3C%20glv_horizon.value%3A%0A%20%20%20%20_warnings.append(f'Run%20ended%20early%20at%20t%3D%7Bglv_end%3A.4g%7D%3B%20%7Cx%7C%3D1000%20is%20an%20excursion%20guard%2C%20not%20a%20biological%20bound.')%0Aif%20min(glv_states.min()%2Cglv_states_near.min())%3C0%3A%0A%20%20%20%20_warnings.append('Negative%20numerical%20abundances%20occurred%3B%20these%20require%20a%20tolerance%20check.%20Signed%20values%20are%20retained%20without%20reflection%20or%20clipping.')%0Amo.vstack(%5Bglv_time_plot%2Cnote_md('Horizontal%20selection%20sets%20the%20interval%20for%20the%20phase%20portrait%2C%20separation%20fit%20and%20peak%20sequence.%20An%20empty%20selection%20uses%20the%20full%20trajectory.')%2C%0A%20%20%20%20*%5Bmo.callout(w%2Ckind%3D'warn')%20for%20w%20in%20_warnings%5D%5D)
ewan_obsidian_ready%0A_range%20%3D%20glv_time_plot.ranges.get('x')%0A_points%20%3D%20glv_time_plot.points%0Aif%20_range%20is%20not%20None%3A%0A%20%20%20%20glv_window%20%3D%20tuple(sorted(map(float%2C_range)))%0Aelif%20_points%3A%0A%20%20%20%20glv_window%20%3D%20(min(float(p%5B'x'%5D)%20for%20p%20in%20_points)%2Cmax(float(p%5B'x'%5D)%20for%20p%20in%20_points))%0Aelse%3A%0A%20%20%20%20glv_window%20%3D%20(0.%2Cfloat(glv_end))%0Aglv_window_mask%20%3D%20(glv_time%3E%3Dglv_window%5B0%5D)%20%26%20(glv_time%3C%3Dglv_window%5B1%5D)%0Aglv_window_ids%20%3D%20np.flatnonzero(glv_window_mask)
ewan_obsidian_ready%0A_fig%20%3D%20make_subplots(rows%3D1%2Ccols%3D2%2Cspecs%3D%5B%5B%7B'type'%3A'scene'%7D%2C%7B'type'%3A'xy'%7D%5D%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20subplot_titles%3D('Three-dimensional%20state'%2C'Projection%20onto%20(x%E2%82%81%2C%20x%E2%82%82)'))%0A_ids%20%3D%20glv_window_ids%0Afor%20_states%2C_name%2C_color%20in%20%5B(glv_states%2C'base'%2Ccolors%5B'pine'%5D)%2C(glv_states_near%2C'nearby'%2Ccolors%5B'rust'%5D)%5D%3A%0A%20%20%20%20_fig.add_trace(go.Scatter3d(x%3D_states%5B_ids%2C0%5D%2Cy%3D_states%5B_ids%2C1%5D%2Cz%3D_states%5B_ids%2C2%5D%2Cmode%3D'lines'%2C%0A%20%20%20%20%20%20%20%20name%3D_name%2Cline%3Ddict(color%3D_color%2Cwidth%3D3))%2C1%2C1)%0A_fig.add_trace(go.Scatter(x%3Dglv_states%5B_ids%2C0%5D%2Cy%3Dglv_states%5B_ids%2C1%5D%2Cmode%3D'markers'%2Cshowlegend%3DFalse%2C%0A%20%20%20%20marker%3Ddict(size%3D3%2Ccolor%3Dglv_states%5B_ids%2C2%5D%2Ccolorscale%3D'Viridis')%2C%0A%20%20%20%20customdata%3Dnp.column_stack(%5Bglv_time%5B_ids%5D%2Cglv_states%5B_ids%2C2%5D%5D)%2C%0A%20%20%20%20hovertemplate%3D'x%E2%82%81%3D%25%7Bx%3A.3f%7D%3Cbr%3Ex%E2%82%82%3D%25%7By%3A.3f%7D%3Cbr%3Ex%E2%82%83%3D%25%7Bcustomdata%5B1%5D%3A.3f%7D%3Cbr%3Et%3D%25%7Bcustomdata%5B0%5D%3A.2f%7D%3Cextra%3E%3C%2Fextra%3E')%2C1%2C2)%0A_fig.update_layout(scene%3Ddict(xaxis_title%3D'x%E2%82%81'%2Cyaxis_title%3D'x%E2%82%82'%2Czaxis_title%3D'x%E2%82%83')%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20xaxis_title%3D'x%E2%82%81'%2Cyaxis_title%3D'x%E2%82%82')%0Amo.vstack(%5Bnote_md(f'**Selected%20interval%3A**%20%7Bglv_window%5B0%5D%3A.2f%7D%E2%80%93%7Bglv_window%5B1%5D%3A.2f%7D%20%C2%B7%20%7Blen(_ids)%7D%20sampled%20states')%2Cstyle(_fig%2C410)%2C%0A%20%20%20%20note_md('Projected%20crossings%20can%20correspond%20to%20different%20x%E2%82%83%20values.%20Uniqueness%20for%20a%20smooth%20autonomous%20ODE%20prevents%20distinct%20orbits%20from%20crossing%20in%20the%20full%20state%20space%2C%20where%20the%20vector%20field%20assigns%20a%20single%20velocity%20to%20each%20state.')%5D)
ewan_obsidian_ready%0Afit_ids%20%3D%20glv_window_ids%5B(glv_separation%5Bglv_window_ids%5D%3E1e-12)%20%26%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20np.isfinite(glv_separation%5Bglv_window_ids%5D)%5D%0Aseparation_slope%20%3D%20None%0Aseparation_r2%20%3D%20None%0Aseparation_fit%20%3D%20None%0Aif%20len(fit_ids)%3E%3D3%20and%20np.ptp(glv_time%5Bfit_ids%5D)%3E0%3A%0A%20%20%20%20_t%20%3D%20glv_time%5Bfit_ids%5D%0A%20%20%20%20_y%20%3D%20np.log(glv_separation%5Bfit_ids%5D)%0A%20%20%20%20_slope%2C_intercept%20%3D%20np.polyfit(_t%2C_y%2C1)%0A%20%20%20%20separation_slope%20%3D%20float(_slope)%0A%20%20%20%20separation_fit%20%3D%20_slope*_t%2B_intercept%0A%20%20%20%20_total%20%3D%20np.sum((_y-_y.mean())**2)%0A%20%20%20%20separation_r2%20%3D%20float(1-np.sum((_y-separation_fit)**2)%2F_total)%20if%20_total%3E0%20else%20None
ewan_obsidian_ready%0A_fig%20%3D%20go.Figure(go.Scatter(x%3Dglv_time%2Cy%3Dnp.where(glv_separation%3E0%2Cglv_separation%2Cnp.nan)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mode%3D'lines'%2Cname%3D'%E2%80%96xnear%20%E2%88%92%20xbase%E2%80%96%E2%82%82'%2Cline%3Ddict(color%3Dcolors%5B'pine'%5D)))%0Aif%20separation_fit%20is%20not%20None%3A%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3Dglv_time%5Bfit_ids%5D%2Cy%3Dnp.exp(separation_fit)%2Cname%3D'Selected-window%20fit'%2Cline%3Ddict(color%3Dcolors%5B'rust'%5D%2Cdash%3D'dash')))%0A_fig.add_vrect(x0%3Dglv_window%5B0%5D%2Cx1%3Dglv_window%5B1%5D%2Cfillcolor%3Dcolors%5B'sage'%5D%2Copacity%3D0.12%2Cline_width%3D0)%0A_fig.update_layout(xaxis_title%3D'Time'%2Cyaxis_title%3D'State%20separation%20(log%20scale)'%2Cyaxis_type%3D'log')%0A_result%20%3D%20'The%20fit%20requires%20at%20least%20three%20selected%20samples%20with%20separation%20above%2010%E2%81%BB%C2%B9%C2%B2.'%20if%20separation_slope%20is%20None%20else%20f'Window%20slope%20of%20log%20separation%3A%20**%7Bseparation_slope%3A.4f%7D%20per%20time%20unit**%3B%20R%C2%B2%20%3D%20%7Bseparation_r2%3A.3f%7D.'%20if%20separation_r2%20is%20not%20None%20else%20f'Window%20slope%3A%20**%7Bseparation_slope%3A.4f%7D%20per%20time%20unit**.'%0Amo.vstack(%5Bstyle(_fig%2C320)%2Cnote_md(_result)%2Cnote_md(r%22%22%22%0AFor%20%24d(t)%5Capprox%20d(0)e%5E%7B%5Clambda%20t%7D%24%2C%20the%20graph%20of%20%24%5Clog%20d(t)%24%20has%20slope%20%24%5Clambda%24.%20The%20fitted%20slope%20measures%20separation%20over%20the%20selected%20interval%3B%20a%20%5B%5BLyapunov%20Exponents%7CLyapunov%20exponent%5D%5D%20additionally%20requires%20control%20of%20perturbation%20size%2C%20tangent%20evolution%20and%20averaging.%20Transient%20growth%2C%20phase%20drift%2C%20saturation%20and%20integration%20error%20can%20all%20affect%20two%20finite%20trajectories.%20Dependence%20on%20the%20selected%20interval%20and%20initial%20perturbation%20therefore%20matters%20when%20interpreting%20%5B%5BSensitive%20Dependence%20on%20Initial%20Conditions%5D%5D%3B%20see%20also%20%5B%5BFinite-Time%20Lyapunov%20Exponent%5D%5D.%20At%20%24%5Cvarepsilon%3D0%24%2C%20the%20trajectories%20coincide%20and%20%24%5Clog%20d%24%20is%20undefined%2C%20so%20zero%20distances%20are%20omitted.%0A%22%22%22)%5D)
ewan_obsidian_ready%0Apeak_species%20%3D%20mo.ui.dropdown(options%3D%7B'x%E2%82%81'%3A0%2C'x%E2%82%82'%3A1%2C'x%E2%82%83'%3A2%7D%2Cvalue%3D'x%E2%82%81'%2Clabel%3D'Population%20for%20peaks')%0Apeak_species
ewan_obsidian_ready%0A%23%20Detect%20on%20the%20full%20uniformly%20sampled%20base%20trajectory%2C%20then%20select%20consecutive%20peak%20pairs.%0A_peak_ids%2C_%20%3D%20find_peaks(glv_states%5B%3A%2Cpeak_species.value%5D)%0Apeak_ids%20%3D%20_peak_ids%5Bglv_window_mask%5B_peak_ids%5D%5D%0Apeak_values%20%3D%20glv_states%5Bpeak_ids%2Cpeak_species.value%5D
11 sampled local maxima in the selected interval. After the transient, one recurring peak height is consistent with a simple cycle, while alternating heights can indicate period doubling. Irregular heights can also arise from transients or numerical sampling. The peak sequence uses sampled maxima, so its resolution depends on the output time grid.
ewan_obsidian_ready%0A_fig%20%3D%20make_subplots(rows%3D1%2Ccols%3D2%2Csubplot_titles%3D('Peak%20sequence%20in%20selected%20interval'%2C'Consecutive%20peaks'))%0A_fig.add_trace(go.Scatter(x%3Dglv_time%5Bpeak_ids%5D%2Cy%3Dpeak_values%2Cmode%3D'lines%2Bmarkers'%2Cname%3D'Peaks')%2C1%2C1)%0A_fig.add_trace(go.Scatter(x%3Dpeak_values%5B%3A-1%5D%2Cy%3Dpeak_values%5B1%3A%5D%2Cmode%3D'markers'%2Cname%3D'Return%20pairs')%2C1%2C2)%0A_fig.update_xaxes(title_text%3D'Time%20of%20peak'%2Crow%3D1%2Ccol%3D1)%0A_fig.update_yaxes(title_text%3D'Peak%20abundance'%2Crow%3D1%2Ccol%3D1)%0A_fig.update_xaxes(title_text%3D'Peak%20n'%2Crow%3D1%2Ccol%3D2)%0A_fig.update_yaxes(title_text%3D'Peak%20n%20%2B%201'%2Crow%3D1%2Ccol%3D2)%0A_message%20%3D%20f'%7Blen(peak_ids)%7D%20sampled%20local%20maxima%20in%20the%20selected%20interval.'%0Aif%20len(peak_ids)%3C3%3A%20_message%20%2B%3D%20'%20Fewer%20than%20three%20peaks%20give%20fewer%20than%20two%20return%20pairs.'%0Amo.vstack(%5Bstyle(_fig%2C320)%2Cnote_md(_message%2B'%20After%20the%20transient%2C%20one%20recurring%20peak%20height%20is%20consistent%20with%20a%20simple%20cycle%2C%20while%20alternating%20heights%20can%20indicate%20period%20doubling.%20Irregular%20heights%20can%20also%20arise%20from%20transients%20or%20numerical%20sampling.%20The%20peak%20sequence%20uses%20sampled%20maxima%2C%20so%20its%20resolution%20depends%20on%20the%20output%20time%20grid.')%5D)
ewan_obsidian_ready%0Anote_md(r%22%22%22%0A%23%23%23%20Numerical%20integration%0A%0AThe%20Colab%20uses%20simultaneous%20forward%20Euler%20updates%20with%20%24h%3D10%5E%7B-4%7D%24%20for%20nearly%20200%20time%20units%2C%20starting%20from%20%24(0.5%2C0.5%2C0.5)%24%20and%20%24(0.51%2C0.51%2C0.49)%24%3A%0A%24%24x_%7Bn%2B1%7D%3Dx_n%2Bh%5C%2Cx_n%5Codot%20A(%5Cmathbf1-x_n).%24%24%0AThe%20trajectories%20above%20use%20DOP853%20with%20relative%20tolerance%20%2410%5E%7B-9%7D%24%20and%20absolute%20tolerance%20%2410%5E%7B-11%7D%24.%20The%204001%20plotted%20times%20are%20output%20samples%3B%20the%20solver%20chooses%20its%20internal%20steps%20adaptively.%20The%20comparison%20below%20runs%20Euler%20at%20%24h%24%20and%20%24h%2F2%24%20against%20a%20tighter%20DOP853%20solution%2C%20using%20the%20model%20inputs%20held%20in%20the%20form%20at%20submission.%20Changing%20the%20model%20resets%20the%20comparison.%0A%0AThe%20continuous%20equations%20preserve%20nonnegative%20populations%20while%20a%20finite%20solution%20exists.%20Forward%20Euler%20can%20violate%20this%2C%20so%20the%20comparison%20stops%20at%20the%20first%20negative%20state%20and%20retains%20its%20signed%20value.%20Reflection%20through%20an%20absolute%20value%20would%20conceal%20the%20numerical%20failure.%0A%22%22%22)
ewan_obsidian_ready%0A%23%20Recreated%20when%20model%20inputs%20change%3A%20the%20expensive%20comparison%20returns%20to%20its%20unsubmitted%20gate.%0A_euler_model%20%3D%20dict(glv_parameters)%0Aeuler_config%20%3D%20mo.ui.dictionary(%7B%0A%20%20%20%20**%7Bk%3Amo.ui.number(value%3D_euler_model%5Bk%5D%2Cdisabled%3DTrue%2Clabel%3Df'Current%20%7Bk%7D')%20for%20k%20in%20('a'%2C'x1'%2C'x2'%2C'x3')%7D%2C%0A%20%20%20%20'h'%3Amo.ui.dropdown(options%3D%5B0.0001%2C0.001%2C0.01%2C0.05%2C0.1%5D%2Cvalue%3D0.01%2Clabel%3D'Euler%20step%20h')%2C%0A%20%20%20%20'T'%3Amo.ui.slider(5%2C100%2Cstep%3D5%2Cvalue%3D20%2Clabel%3D'Comparison%20horizon')%2C%0A%7D).form(submit_button_label%3D'Compare%20Euler%20steps'%2Cshow_clear_button%3DTrue)%0Aeuler_config
ewan_obsidian_ready%0Amo.stop(euler_config.value%20is%20None%2Cnote_md('The%20integration%20comparison%20runs%20on%20submission.'))%0Aeuler_run%20%3D%20dict(a%3Deuler_config.value%5B'a'%5D%2Cx0%3Dnp.array(%5Beuler_config.value%5Bk%5D%20for%20k%20in%20('x1'%2C'x2'%2C'x3')%5D)%2Ch%3Deuler_config.value%5B'h'%5D%2CT%3Deuler_config.value%5B'T'%5D)%0Aeuler_coarse%20%3D%20forward_euler(interaction_matrix(euler_run%5B'a'%5D)%2Ceuler_run%5B'x0'%5D%2Ceuler_run%5B'T'%5D%2Ceuler_run%5B'h'%5D)%0Aeuler_fine%20%3D%20forward_euler(interaction_matrix(euler_run%5B'a'%5D)%2Ceuler_run%5B'x0'%5D%2Ceuler_run%5B'T'%5D%2Ceuler_run%5B'h'%5D%2F2)%0Aeuler_reference%20%3D%20integrate_glv(interaction_matrix(euler_run%5B'a'%5D)%2Ceuler_run%5B'x0'%5D%2Ceuler_run%5B'T'%5D%2Crtol%3D1e-11%2Catol%3D1e-13)
ewan_obsidian_ready%0A_fig%20%3D%20go.Figure()%0A_summary%3D%5B%5D%0Afor%20_run%2C_name%20in%20%5B(euler_coarse%2C'h')%2C(euler_fine%2C'h%2F2')%5D%3A%0A%20%20%20%20_t%2C_x%2C_status%2C_dt%20%3D%20_run%0A%20%20%20%20_mask%20%3D%20_t%3C%3Deuler_reference.t%5B-1%5D%0A%20%20%20%20_err%20%3D%20np.linalg.norm(_x%5B_mask%5D-euler_reference.sol(_t%5B_mask%5D).T%2Caxis%3D1)%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D_t%5B_mask%5D%2Cy%3D_err%2Cmode%3D'lines'%2Cname%3Df'%7B_name%7D%20%3D%20%7B_dt%3Ag%7D'))%0A%20%20%20%20_summary.append(f'%7B_name%7D%3A%20%7B_status%7D%3B%20maximum%20sampled%20error%20%7B_err.max()%3A.3g%7D')%0A_fig.update_layout(xaxis_title%3D'Time'%2Cyaxis_title%3D'%E2%80%96Euler%20%E2%88%92%20tighter%20DOP853%E2%80%96%E2%82%82')%0Amo.vstack(%5Bstyle(_fig%2C320)%2Cnote_md('%3B%20'.join(_summary))%2C%0A%20%20%20%20note_md(f%22Comparison%3A%20a%3D%7Beuler_run%5B'a'%5D%3Ag%7D%2C%20x%E2%82%80%3D%7Beuler_run%5B'x0'%5D.tolist()%7D%2C%20T%3D%7Beuler_run%5B'T'%5D%3Ag%7D.%20On%20a%20fixed%20smooth%20interval%20in%20the%20convergence%20regime%2C%20Euler%20has%20global%20error%20O(h)%2C%20so%20halving%20h%20approximately%20halves%20the%20error.%20Sensitive%20dynamics%20can%20produce%20large%20long-time%20trajectory%20errors%20without%20changing%20the%20underlying%20attractor.%22)%5D)
The stochastic panda model in Continuous models retains extinction events that disappear under a mean-field approximation. Starting from one wild panda, capture or death can occur before reproduction. The lecture compared 200 runs per capture rate with the deterministic trajectory; standard-deviation bars describe variation across runs, whereas standard errors would describe uncertainty in the estimated mean. The original stochastic runs are unavailable here.
A discrete intervention is a jump applied once at a specified time. With an adaptive solver, integration proceeds to the intervention, the state is changed, and integration restarts. Applying the jump inside the right-hand side makes it depend on the solver evaluation schedule, since the same interval can require repeated evaluations. The lecture ended with oscillations, possible period doubling and separation of nearby trajectories. A finite trajectory cannot establish nonperiodicity for all future time. For smooth autonomous planar flows, uniqueness prevents orbit crossings and the Poincaré–Bendixson restrictions exclude strange attractors under their usual hypotheses. Discrete maps and periodically forced systems need separate treatment.
A projected figure eight can hide separation in a third coordinate. Its two lobes do not establish two centers, and an attracting periodic orbit has different local geometry from a center surrounded by closed orbits. Peak sequences and trajectory separation give finite-time evidence about the simulated dynamics; a chaos classification requires further analysis.
ewan_obsidian_ready%0Amo.accordion(%7B'Stochastic%20extinction%20and%20interventions'%3Anote_md(r%22%22%22%0AThe%20stochastic%20panda%20model%20in%20%5B%5Bcontinuous_models.marimo%7CContinuous%20models%5D%5D%20retains%20extinction%20events%20that%20disappear%20under%20a%20mean-field%20approximation.%20Starting%20from%20one%20wild%20panda%2C%20capture%20or%20death%20can%20occur%20before%20reproduction.%20The%20lecture%20compared%20200%20runs%20per%20capture%20rate%20with%20the%20deterministic%20trajectory%3B%20standard-deviation%20bars%20describe%20variation%20across%20runs%2C%20whereas%20standard%20errors%20would%20describe%20uncertainty%20in%20the%20estimated%20mean.%20The%20original%20stochastic%20runs%20are%20unavailable%20here.%0A%0AA%20discrete%20intervention%20is%20a%20jump%20applied%20once%20at%20a%20specified%20time.%20With%20an%20adaptive%20solver%2C%20integration%20proceeds%20to%20the%20intervention%2C%20the%20state%20is%20changed%2C%20and%20integration%20restarts.%20Applying%20the%20jump%20inside%20the%20right-hand%20side%20makes%20it%20depend%20on%20the%20solver%20evaluation%20schedule%2C%20since%20the%20same%20interval%20can%20require%20repeated%20evaluations.%0A%22%22%22)%2C%20'Period%20doubling%20and%20chaos'%3Anote_md(r%22%22%22%0AThe%20lecture%20ended%20with%20oscillations%2C%20possible%20period%20doubling%20and%20separation%20of%20nearby%20trajectories.%20A%20finite%20trajectory%20cannot%20establish%20nonperiodicity%20for%20all%20future%20time.%20For%20smooth%20autonomous%20planar%20flows%2C%20uniqueness%20prevents%20orbit%20crossings%20and%20the%20Poincar%C3%A9%E2%80%93Bendixson%20restrictions%20exclude%20strange%20attractors%20under%20their%20usual%20hypotheses.%20Discrete%20maps%20and%20periodically%20forced%20systems%20need%20separate%20treatment.%0A%0AA%20projected%20figure%20eight%20can%20hide%20separation%20in%20a%20third%20coordinate.%20Its%20two%20lobes%20do%20not%20establish%20two%20centers%2C%20and%20an%20attracting%20periodic%20orbit%20has%20different%20local%20geometry%20from%20a%20center%20surrounded%20by%20closed%20orbits.%20Peak%20sequences%20and%20trajectory%20separation%20give%20finite-time%20evidence%20about%20the%20simulated%20dynamics%3B%20a%20chaos%20classification%20requires%20further%20analysis.%0A%22%22%22)%7D)
Generalized Lotka–Volterra , downloaded September 25, 2026. SHA-256: e0a4688b0fde24a90103181adfb362d44fd8a68d1b4dceb101e95e404ec7e5a9.
Lecture: September 24, 2026, nominally 14:40–16:05 EDT. Transcript retrieval covered 14:20–16:25 to allow for a suspected timestamp offset, yielding 1097 turns. Identifiable lecture content spans approximately 14:50–16:06 in the index, including the adjacent closing remarks. No clock correction was established. Transcription and segment timing are automated and were not checked by listening; mathematical notation was reconciled with the equations. Retrieval reported 112 indexed recordings and one omitted untimed segment from an incompletely indexed session. The references below retain the transcript revisions; coverage may be incomplete.
The linked Chaos Theory notes develop the discrete-map version of local stability. The conserved quantity, continuous-flow neighborhood comparison, generalized-model Jacobian and numerical diagnostics supplement the lecture. Further references: MIT nonlinear systems and SciPy solve_ivp .
ewan_obsidian_ready%0Asource_anchors%20%3D%20%5B%7B'topic'%3A%20'Opening%20and%20mean-field%20context'%2C%20'indexed_utc'%3A%20'2026-09-24T18%3A50%3A07.315769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2Feffb9e69-51b7-5f49-9dbd-acbccb5f3475%3Ac0573562ea5274ee7d1a2358fcd9afbed9b9b98c5a382fe0328e0ad5a123f497%3A7'%2C%20'session_id'%3A%20'effb9e69-51b7-5f49-9dbd-acbccb5f3475'%2C%20'transcript_sha256'%3A%20'c0573562ea5274ee7d1a2358fcd9afbed9b9b98c5a382fe0328e0ad5a123f497'%7D%2C%20%7B'topic'%3A%20'Stochastic%20panda%20recap'%2C%20'indexed_utc'%3A%20'2026-09-24T18%3A56%3A38.435769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2Fcef3acdc-119f-58fa-bf9b-b47f926eb04f%3A3c97c67d4d0e43ef8785479bace47113332c02e26c5f3bd4a22c7e62e0948736%3A0'%2C%20'session_id'%3A%20'cef3acdc-119f-58fa-bf9b-b47f926eb04f'%2C%20'transcript_sha256'%3A%20'3c97c67d4d0e43ef8785479bace47113332c02e26c5f3bd4a22c7e62e0948736'%7D%2C%20%7B'topic'%3A%20'Predator%E2%80%93prey%20analysis'%2C%20'indexed_utc'%3A%20'2026-09-24T19%3A01%3A00.535769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2F846b0197-76c6-5f01-9034-937864427578%3Acc8ac9679a5f26cb268f1a6ae6628ec1f588b0d3055ab180d400f618cf61c56a%3A4'%2C%20'session_id'%3A%20'846b0197-76c6-5f01-9034-937864427578'%2C%20'transcript_sha256'%3A%20'cc8ac9679a5f26cb268f1a6ae6628ec1f588b0d3055ab180d400f618cf61c56a'%7D%2C%20%7B'topic'%3A%20'Jacobian%20entries'%2C%20'indexed_utc'%3A%20'2026-09-24T19%3A15%3A45.135769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2Fab6b0fa5-91bd-5d89-b5a1-05a5b3d495e0%3A5fb1365234cd6a992bd10c6c829e6e3314bc143027c755a1f4fb1f201778278f%3A1'%2C%20'session_id'%3A%20'ab6b0fa5-91bd-5d89-b5a1-05a5b3d495e0'%2C%20'transcript_sha256'%3A%20'5fb1365234cd6a992bd10c6c829e6e3314bc143027c755a1f4fb1f201778278f'%7D%2C%20%7B'topic'%3A%20'Saddle%20classification'%2C%20'indexed_utc'%3A%20'2026-09-24T19%3A26%3A19.205769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2F8e8c8c8d-6329-5638-8f09-1e18c9463f04%3Af4f63526f4b0452159cc41bfef35897518c922b767c2973e07550950034f427c%3A5'%2C%20'session_id'%3A%20'8e8c8c8d-6329-5638-8f09-1e18c9463f04'%2C%20'transcript_sha256'%3A%20'f4f63526f4b0452159cc41bfef35897518c922b767c2973e07550950034f427c'%7D%2C%20%7B'topic'%3A%20'Coexistence%20trace%20and%20determinant'%2C%20'indexed_utc'%3A%20'2026-09-24T19%3A34%3A12.535769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2Fa7c01d0d-d14a-59ab-aba2-1efe3ad863f2%3Abdd42d984519e79fd7c86bd114e4c5164b1842135df83faba124b9c476f37326%3A9'%2C%20'session_id'%3A%20'a7c01d0d-d14a-59ab-aba2-1efe3ad863f2'%2C%20'transcript_sha256'%3A%20'bdd42d984519e79fd7c86bd114e4c5164b1842135df83faba124b9c476f37326'%7D%2C%20%7B'topic'%3A%20'Neighboring%20orbits'%2C%20'indexed_utc'%3A%20'2026-09-24T19%3A40%3A45.235769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2Fb23f8f8e-14d8-55b1-b5dd-e29c166fd4ae%3A2a7d032448a5744d0d2130b69a02bab08c8fc4d7be2dff22801a2de80ad5580c%3A4'%2C%20'session_id'%3A%20'b23f8f8e-14d8-55b1-b5dd-e29c166fd4ae'%2C%20'transcript_sha256'%3A%20'2a7d032448a5744d0d2130b69a02bab08c8fc4d7be2dff22801a2de80ad5580c'%7D%2C%20%7B'topic'%3A%20'Generalized%20model'%2C%20'indexed_utc'%3A%20'2026-09-24T19%3A49%3A22.635769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2F58f0ae7c-9c55-5f94-8c35-672c2c1b15fa%3Adb8a0fcda239ce0475af220083919acb69560f404439746e2d74e982f227ec6c%3A5'%2C%20'session_id'%3A%20'58f0ae7c-9c55-5f94-8c35-672c2c1b15fa'%2C%20'transcript_sha256'%3A%20'db8a0fcda239ce0475af220083919acb69560f404439746e2d74e982f227ec6c'%7D%2C%20%7B'topic'%3A%20'Nearby%20initial%20states'%2C%20'indexed_utc'%3A%20'2026-09-24T20%3A00%3A13.975769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2F335e6e57-fdef-583f-90af-89aa7bb3fa1d%3A72416737e423d9fd25a24d7cb2ac2f233ee744425b7fe67a870ced6b46bec4d7%3A7'%2C%20'session_id'%3A%20'335e6e57-fdef-583f-90af-89aa7bb3fa1d'%2C%20'transcript_sha256'%3A%20'72416737e423d9fd25a24d7cb2ac2f233ee744425b7fe67a870ced6b46bec4d7'%7D%2C%20%7B'topic'%3A%20'Period-doubling%20discussion'%2C%20'indexed_utc'%3A%20'2026-09-24T20%3A02%3A58.805769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2F84d5cdcb-7579-534a-9401-7a39e41cfec5%3A3f11b336c3f4d382adc1c0abc95e961044695aa0710727801a95dfa67e2a6c18%3A3'%2C%20'session_id'%3A%20'84d5cdcb-7579-534a-9401-7a39e41cfec5'%2C%20'transcript_sha256'%3A%20'3f11b336c3f4d382adc1c0abc95e961044695aa0710727801a95dfa67e2a6c18'%7D%2C%20%7B'topic'%3A%20'Adjacent%20closing%20remarks%2C%20beyond%20requested%20end'%2C%20'indexed_utc'%3A%20'2026-09-24T20%3A05%3A26.105769Z'%2C%20'source_ref'%3A%20'%2Fv1%2Faudio%2Fturns%2F09a14cf3-7877-5eb0-9af5-8aef5a825dbb%3A1dc1cbb42badbe86e011b0e96412d6132e614c5a8c65394307058aecb03ef750%3A12'%2C%20'session_id'%3A%20'09a14cf3-7877-5eb0-9af5-8aef5a825dbb'%2C%20'transcript_sha256'%3A%20'1dc1cbb42badbe86e011b0e96412d6132e614c5a8c65394307058aecb03ef750'%7D%5D%0Amo.accordion(%7B'Sources%20and%20timing'%3Amo.vstack(%5Bnote_md(r%22%22%22%0A%5BGeneralized%20Lotka%E2%80%93Volterra%5D(https%3A%2F%2Fcolab.research.google.com%2Fdrive%2F1z3Fr_6V6gS89W5vkpje1NVphb3H1Bz0Q%3Fusp%3Dsharing)%2C%20downloaded%20September%2025%2C%202026.%20SHA-256%3A%20%60e0a4688b0fde24a90103181adfb362d44fd8a68d1b4dceb101e95e404ec7e5a9%60.%0A%0ALecture%3A%20September%2024%2C%202026%2C%20nominally%2014%3A40%E2%80%9316%3A05%20EDT.%20Transcript%20retrieval%20covered%2014%3A20%E2%80%9316%3A25%20to%20allow%20for%20a%20suspected%20timestamp%20offset%2C%20yielding%201097%20turns.%20Identifiable%20lecture%20content%20spans%20approximately%2014%3A50%E2%80%9316%3A06%20in%20the%20index%2C%20including%20the%20adjacent%20closing%20remarks.%20No%20clock%20correction%20was%20established.%20Transcription%20and%20segment%20timing%20are%20automated%20and%20were%20not%20checked%20by%20listening%3B%20mathematical%20notation%20was%20reconciled%20with%20the%20equations.%20Retrieval%20reported%20112%20indexed%20recordings%20and%20one%20omitted%20untimed%20segment%20from%20an%20incompletely%20indexed%20session.%20The%20references%20below%20retain%20the%20transcript%20revisions%3B%20coverage%20may%20be%20incomplete.%0A%0AThe%20linked%20Chaos%20Theory%20notes%20develop%20the%20discrete-map%20version%20of%20local%20stability.%20The%20conserved%20quantity%2C%20continuous-flow%20neighborhood%20comparison%2C%20generalized-model%20Jacobian%20and%20numerical%20diagnostics%20supplement%20the%20lecture.%20Further%20references%3A%20%5BMIT%20nonlinear%20systems%5D(https%3A%2F%2Focw.mit.edu%2Fcourses%2F18-03sc-differential-equations-fall-2011%2Fpages%2Funit-iv-first-order-systems%2Fnonlinear-systems%2F)%20and%20%5BSciPy%20solve_ivp%5D(https%3A%2F%2Fdocs.scipy.org%2Fdoc%2Fscipy%2Freference%2Fgenerated%2Fscipy.integrate.solve_ivp.html).%0A%22%22%22)%2Cmo.ui.table(source_anchors%2Cselection%3DNone)%5D)%7D)