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.36'%2C%20'plotly%3D%3D5.24.1'%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%2Fcontinuous_models%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
ewan_obsidian_ready%0Amo.md(r%22%22%22%0A%23%23%20Continuous%20models%0A%0AGoing%20from%20the%20slope%20to%20the%20next%20point%20with%20%5B%5BEulers%20Method%5D%5D%3A%0A%0A%24%24%5Cdot%7B%5Cmathbf%7Bx%7D%7D%3Df(t%2C%5Cmathbf%7Bx%7D)%5Cquad%5CRightarrow%5Cquad%20%5Cmathbf%7Bx%7D_%7Bn%2B1%7D%3D%5Cmathbf%7Bx%7D_n%2Bh%20f(t_n%2C%5Cmathbf%7Bx%7D_n).%24%24%0A%0AWe%20calculate%20the%20slopes%20**before%20updating%20anything**.%20Otherwise%20the%20second%20equation%20would%20be%20using%20a%20different%20state%20from%20the%20first.%0A%0A%23%23%23%20Panda%20capture%0A%0A%24W%24%20is%20wild%2C%20%24D%24%20is%20domesticated.%20Birth%20rate%20%24%5Cmu%24%2C%20death%20rate%20%24%5Cnu%24%2C%20capture%20rate%20%24%5Cbeta%24%3A%0A%0A%24%24%5Cbegin%7Baligned%7D%0A%5Cdot%20W%26%3D-%5Cbeta%20W-%5Cnu_wW%2B%5Cmu_wW%5Cleft(1-%5Cfrac%7BW%7D%7BK_w%7D%5Cright)%2C%5C%5C%0A%5Cdot%20D%26%3D%5Cbeta%20W-%5Cnu_dD%2B%5Cmu_dD%5Cleft(1-%5Cfrac%7BD%7D%7BK_d%7D%5Cright).%0A%5Cend%7Baligned%7D%24%24%0A%0AThe%20%24K%24%20terms%20limit%20reproduction.%20Capturing%20more%20pandas%20helps%20the%20zoo%2C%20but%20leaves%20fewer%20in%20the%20wild%20to%20reproduce.%20So%20there%20should%20be%20some%20capture%20rate%20between%20*none*%20and%20*everything*%20which%20does%20best.%0A%22%22%22)
ewan_obsidian_ready%0Afrom%20wigglystuff%20import%20TangleLatex%0A%0Apanda_inputs%20%3D%20mo.ui.anywidget(TangleLatex(%0A%20%20%20%20theme%3D%22light%22%2C%0A%20%20%20%20latex%3Dr%22%5Cbegin%7Baligned%7DW_0%20%26%3D%20%5Ctangle%7Bw0%7D%2C%20%26%20D_0%20%26%3D%20%5Ctangle%7Bd0%7D%20%5C%5C%20K_w%20%26%3D%20%5Ctangle%7Bkw%7D%2C%20%26%20K_d%20%26%3D%20%5Ctangle%7Bkd%7D%20%5C%5C%20%5Cmu_w%20%26%3D%20%5Ctangle%7Bmuw%7D%2C%20%26%20%5Cmu_d%20%26%3D%20%5Ctangle%7Bmud%7D%20%5C%5C%20%5Cnu_w%20%26%3D%20%5Ctangle%7Bnuw%7D%2C%20%26%20%5Cnu_d%20%26%3D%20%5Ctangle%7Bnud%7D%5Cend%7Baligned%7D%22%2C%0A%20%20%20%20parameters%3D%7B%0A%20%20%20%20%20%20%20%20%22w0%22%3A%20%7B%22value%22%3A%201%2C%20%22min_value%22%3A%200%2C%20%22max_value%22%3A%20200%2C%20%22step%22%3A%201%2C%20%22digits%22%3A%200%7D%2C%0A%20%20%20%20%20%20%20%20%22d0%22%3A%20%7B%22value%22%3A%200%2C%20%22min_value%22%3A%200%2C%20%22max_value%22%3A%20100%2C%20%22step%22%3A%201%2C%20%22digits%22%3A%200%7D%2C%0A%20%20%20%20%20%20%20%20%22kw%22%3A%20%7B%22value%22%3A%20100%2C%20%22min_value%22%3A%201%2C%20%22max_value%22%3A%20300%2C%20%22step%22%3A%201%2C%20%22digits%22%3A%200%7D%2C%0A%20%20%20%20%20%20%20%20%22kd%22%3A%20%7B%22value%22%3A%2025%2C%20%22min_value%22%3A%201%2C%20%22max_value%22%3A%20100%2C%20%22step%22%3A%201%2C%20%22digits%22%3A%200%7D%2C%0A%20%20%20%20%20%20%20%20%22muw%22%3A%20%7B%22value%22%3A%201.0%2C%20%22min_value%22%3A%200.01%2C%20%22max_value%22%3A%202%2C%20%22step%22%3A%200.01%2C%20%22digits%22%3A%202%7D%2C%0A%20%20%20%20%20%20%20%20%22mud%22%3A%20%7B%22value%22%3A%200.1%2C%20%22min_value%22%3A%200.01%2C%20%22max_value%22%3A%202%2C%20%22step%22%3A%200.01%2C%20%22digits%22%3A%202%7D%2C%0A%20%20%20%20%20%20%20%20%22nuw%22%3A%20%7B%22value%22%3A%200.5%2C%20%22min_value%22%3A%200%2C%20%22max_value%22%3A%202%2C%20%22step%22%3A%200.01%2C%20%22digits%22%3A%202%7D%2C%0A%20%20%20%20%20%20%20%20%22nud%22%3A%20%7B%22value%22%3A%200.5%2C%20%22min_value%22%3A%200%2C%20%22max_value%22%3A%202%2C%20%22step%22%3A%200.01%2C%20%22digits%22%3A%202%7D%2C%0A%20%20%20%20%7D%2C%0A))%0Apanda_inputs
ewan_obsidian_ready%0AW0%20%3D%20panda_inputs.values%5B%22w0%22%5D%0AD0%20%3D%20panda_inputs.values%5B%22d0%22%5D%0AK_w%20%3D%20panda_inputs.values%5B%22kw%22%5D%0AK_d%20%3D%20panda_inputs.values%5B%22kd%22%5D%0Amu_w%20%3D%20panda_inputs.values%5B%22muw%22%5D%0Amu_d%20%3D%20panda_inputs.values%5B%22mud%22%5D%0Anu_w%20%3D%20panda_inputs.values%5B%22nuw%22%5D%0Anu_d%20%3D%20panda_inputs.values%5B%22nud%22%5D%0Abetas%20%3D%20np.arange(0.0%2C%201.0%2C%200.01)
ewan_obsidian_ready%0Astep_size%20%3D%20mo.ui.dropdown(options%3D%5B0.005%2C%200.01%2C%200.02%2C%200.05%2C%200.1%5D%2C%20value%3D0.01%2C%20label%3D%22Step%20h%22)%0Ahorizon%20%3D%20mo.ui.slider(start%3D20%2C%20stop%3D200%2C%20step%3D20%2C%20value%3D100%2C%20label%3D%22Time%20T%22)%0Acapture_rate%20%3D%20mo.ui.slider(start%3D0%2C%20stop%3D1%2C%20step%3D0.01%2C%20value%3D0.25%2C%20label%3D%22Capture%20%CE%B2%22)%0Amo.hstack(%5Bstep_size%2C%20horizon%2C%20capture_rate%5D)
ewan_obsidian_ready%0Adef%20panda_rhs(W%2C%20D%2C%20beta)%3A%0A%20%20%20%20dot_W%20%3D%20-beta%20*%20W%20-%20nu_w%20*%20W%20%2B%20mu_w%20*%20W%20*%20(1%20-%20W%20%2F%20K_w)%0A%20%20%20%20dot_D%20%3D%20beta%20*%20W%20-%20nu_d%20*%20D%20%2B%20mu_d%20*%20D%20*%20(1%20-%20D%20%2F%20K_d)%0A%20%20%20%20return%20dot_W%2C%20dot_D%0A%0A%0Adef%20euler_pandas(beta%2C%20h%2C%20T)%3A%0A%20%20%20%20steps%20%3D%20int(np.ceil(T%20%2F%20h))%0A%20%20%20%20time%20%3D%20np.linspace(0.0%2C%20T%2C%20steps%20%2B%201)%0A%20%20%20%20W%20%3D%20np.full(np.shape(beta)%2C%20W0%2C%20dtype%3Dfloat)%0A%20%20%20%20D%20%3D%20np.full(np.shape(beta)%2C%20D0%2C%20dtype%3Dfloat)%0A%20%20%20%20history%20%3D%20np.empty((steps%20%2B%201%2C%202)%20%2B%20np.shape(beta))%0A%20%20%20%20history%5B0%5D%20%3D%20W%2C%20D%0A%20%20%20%20for%20n%2C%20dt%20in%20enumerate(np.diff(time))%3A%0A%20%20%20%20%20%20%20%20dot_W%2C%20dot_D%20%3D%20panda_rhs(W%2C%20D%2C%20beta)%0A%20%20%20%20%20%20%20%20W%2C%20D%20%3D%20W%20%2B%20dt%20*%20dot_W%2C%20D%20%2B%20dt%20*%20dot_D%0A%20%20%20%20%20%20%20%20history%5Bn%20%2B%201%5D%20%3D%20W%2C%20D%0A%20%20%20%20return%20time%2C%20history
ewan_obsidian_ready%0Atimes%2C%20trajectory%20%3D%20euler_pandas(capture_rate.value%2C%20step_size.value%2C%20horizon.value)
ewan_obsidian_ready%0Asweep_times%2C%20sweep%20%3D%20euler_pandas(betas%2C%20step_size.value%2C%20horizon.value)%0Afinal_D%20%3D%20sweep%5B-1%2C%201%5D%0Abest_beta%20%3D%20float(betas%5Bnp.argmax(final_D)%5D)%0Abeta_star%20%3D%20(mu_w%20-%20nu_w)%20%2F%202%0Awild_equilibrium%20%3D%20K_w%20*%20np.maximum(0%2C%201%20-%20(betas%20%2B%20nu_w)%20%2F%20mu_w)%0Aimmigration%20%3D%20betas%20*%20wild_equilibrium%0Adomestic_equilibrium%20%3D%20((mu_d%20-%20nu_d)%20%2B%20np.sqrt((mu_d%20-%20nu_d)**2%20%2B%204%20*%20mu_d%20*%20immigration%20%2F%20K_d))%20%2F%20(2%20*%20mu_d%20%2F%20K_d)%0Aresidual%20%3D%20max(float(np.max(np.abs(v)))%20for%20v%20in%20panda_rhs(sweep%5B-1%2C%200%5D%2C%20sweep%5B-1%2C%201%5D%2C%20betas))
ewan_obsidian_ready%0A_fig%20%3D%20make_subplots(rows%3D1%2C%20cols%3D2%2C%20subplot_titles%3D(%22Panda%20phase%20space%22%2C%20%22Capture%20sweep%22))%0A_fig.add_trace(go.Scatter(x%3Dtrajectory%5B%3A%2C0%5D%2Cy%3Dtrajectory%5B%3A%2C1%5D%2Cname%3D%22Trajectory%22%2Cline%3Ddict(color%3D%22%2356706b%22))%2C1%2C1)%0A_fig.add_trace(go.Scatter(x%3D%5BW0%5D%2Cy%3D%5BD0%5D%2Cmode%3D%22markers%22%2Cname%3D%22Initial%20state%22%2Cmarker%3Ddict(symbol%3D%22diamond%22%2Csize%3D8%2Ccolor%3D%22%232d2520%22))%2C1%2C1)%0A_w%20%3D%20np.linspace(0%2CK_w%2C200)%0A_dnull%20%3D%20((mu_d-nu_d)%2Bnp.sqrt((mu_d-nu_d)**2%2B4*mu_d*capture_rate.value*_w%2FK_d))%2F(2*mu_d%2FK_d)%0A_fig.add_trace(go.Scatter(x%3D_w%2Cy%3D_dnull%2Cname%3D%22D%CC%87%20%3D%200%22%2Cline%3Ddict(dash%3D%22dot%22%2Ccolor%3D%22%23a67c6d%22))%2C1%2C1)%0A_wstar%20%3D%20K_w*(1-(capture_rate.value%2Bnu_w)%2Fmu_w)%0Afor%20_wline%20in%20%5B0%2C_wstar%5D%20if%20_wstar%3E0%20else%20%5B0%5D%3A%0A%20%20%20%20_fig.add_vline(x%3D_wline%2Cline_dash%3D%22dash%22%2Cline_color%3D%22%23728c99%22%2Crow%3D1%2Ccol%3D1)%0A_fig.add_trace(go.Scatter(x%3Dbetas%2Cy%3Dfinal_D%2Cname%3D%22Euler%20D(T)%22%2Cline%3Ddict(color%3D%22%2356706b%22))%2C1%2C2)%0A_fig.add_trace(go.Scatter(x%3Dbetas%2Cy%3Ddomestic_equilibrium%2Cname%3D%22D*%22%2Cline%3Ddict(dash%3D%22dash%22%2Ccolor%3D%22%23a67c6d%22))%2C1%2C2)%0A_fig.add_vline(x%3Dcapture_rate.value%2Cline_color%3D%22%232d2520%22%2Crow%3D1%2Ccol%3D2)%0A_fig.add_vline(x%3Dbeta_star%2Cline_dash%3D%22dot%22%2Crow%3D1%2Ccol%3D2)%0A_fig.update_xaxes(title_text%3D%22Wild%20W%22%2Crange%3D%5B0%2CK_w%5D%2Crow%3D1%2Ccol%3D1)%0A_fig.update_yaxes(title_text%3D%22Domesticated%20D%22%2Crow%3D1%2Ccol%3D1)%0A_fig.update_xaxes(title_text%3D%22Capture%20%CE%B2%22%2Crow%3D1%2Ccol%3D2)%0A_fig.update_yaxes(title_text%3D%22Domesticated%20D%22%2Crow%3D1%2Ccol%3D2)%0A_fig.update_layout(height%3D380%2Cmargin%3Ddict(l%3D45%2Cr%3D15%2Ct%3D40%2Cb%3D40)%2Clegend%3Ddict(orientation%3D%22h%22%2Cy%3D-.23)%2Cuirevision%3D%22pandas%22)%0A_fig
ewan_obsidian_ready%0Amo.md(f%22%22%22%0A**Finite%20time%20vs%20fixed%20point%3A**%20the%20sweep%20peaks%20at%20%CE%B2%20%3D%20%7Bbest_beta%3A.2f%7D%3B%20the%20prediction%20is%20%7Bbeta_star%3A.2f%7D.%20Increase%20T%20to%20see%20whether%20the%20curve%20has%20settled.%20Dashed%20vertical%20lines%20in%20the%20phase%20portrait%20are%20W%CC%87%20%3D%200%3B%20the%20dotted%20curve%20is%20D%CC%87%20%3D%200.%0A%22%22%22)
ewan_obsidian_ready%0Amo.md(r%22%22%22%0A%23%23%23%20Where%20does%20the%20optimum%20come%20from%3F%0A%0ASetting%20%24%5Cdot%20W%3D0%24%20gives%20two%20solutions%3A%0A%0A%24%24W_1%3D0%2C%5Cqquad%20W_2%3DK_w%5Cleft(1-%5Cfrac%7B%5Cbeta%2B%5Cnu_w%7D%7B%5Cmu_w%7D%5Cright).%24%24%0A%0A%24W_2%24%20only%20makes%20physical%20sense%20when%20%24%5Cbeta%3C%5Cmu_w-%5Cnu_w%24.%20The%20supply%20to%20the%20zoo%20is%20then%0A%0A%24%24J(%5Cbeta)%3D%5Cbeta%20W_2%3D%5Cfrac%7BK_w%7D%7B%5Cmu_w%7D%5Cbeta(%5Cmu_w-%5Cnu_w-%5Cbeta).%24%24%0A%0AMore%20supply%20gives%20a%20larger%20domestic%20fixed%20point.%20So%20we%20just%20maximize%20%24J%24%3A%0A%0A%24%24J'(%5Cbeta)%3D0%5Cquad%5CRightarrow%5Cquad%20%5Cbeta%5E*%3D%5Cfrac%7B%5Cmu_w-%5Cnu_w%7D%7B2%7D%3D0.25.%24%24%0A%0AThis%20assumes%20%24%5Cmu_w%3E%5Cnu_w%24%20and%20that%20we%20can%20choose%20this%20capture%20rate.%20It%20is%20a%20long-term%20prediction%3B%20the%20best%20rate%20over%20a%20short%20interval%20can%20be%20different.%0A%22%22%22)
ewan_obsidian_ready%0Amo.md(r%22%22%22%0A%23%23%20Event-time%20panda%20simulation%0A%0ANow%20the%20populations%20are%20integer%20counts.%20Each%20event%20changes%20them%20by%20one%3B%20time%20jumps%20by%20a%20random%20amount.%20For%20event%20rates%20%5C(a_j(W%2CD)%5C)%2C%20let%20%5C(A%3D%5Csum_j%20a_j%5C).%20Then%0A%0A%5C%5B%0A%5Ctau%20%5Csim%20%5Coperatorname%7BExponential%7D(%5Ctext%7Brate%20%7DA)%2C%5Cqquad%0AP(%5Ctext%7Bnext%20event%7D%3Dj%5Cmid%20W%2CD)%3D%5Cfrac%7Ba_j%7D%7BA%7D.%0A%5C%5D%0A%0AThe%20exponential%20sampler%20takes%20**scale**%20%5C(1%2FA%5C)%2C%20not%20%5C(A%5C).%20Store%20both%20event%20times%20and%20states%20because%20event%20index%20is%20no%20longer%20a%20time%20step.%20If%20%5C(A%3D0%5C)%2C%20the%20state%20is%20absorbing.%0A%0A%7C%20Event%20%7C%20%5C(%5CDelta%20W%5C)%20%7C%20%5C(%5CDelta%20D%5C)%20%7C%20Rate%20%7C%0A%7C---%7C---%3A%7C---%3A%7C---%3A%7C%0A%7C%20Wild%20birth%20%7C%20%2B1%20%7C%200%20%7C%20%5C(%5Cmu_w%20W%5C)%20%7C%0A%7C%20Wild%20crowding%20death%20%7C%20%E2%88%921%20%7C%200%20%7C%20%5C(%5Cmu_w%20W%5E2%2FK_w%5C)%20%7C%0A%7C%20Wild%20ordinary%20death%20%7C%20%E2%88%921%20%7C%200%20%7C%20%5C(%5Cnu_w%20W%5C)%20%7C%0A%7C%20Capture%20%7C%20%E2%88%921%20%7C%20%2B1%20%7C%20%5C(%5Cbeta%20W%5C)%20%7C%0A%7C%20Domestic%20birth%20%7C%200%20%7C%20%2B1%20%7C%20%5C(%5Cmu_d%20D%5C)%20%7C%0A%7C%20Domestic%20crowding%20death%20%7C%200%20%7C%20%E2%88%921%20%7C%20%5C(%5Cmu_d%20D%5E2%2FK_d%5C)%20%7C%0A%7C%20Domestic%20ordinary%20death%20%7C%200%20%7C%20%E2%88%921%20%7C%20%5C(%5Cnu_d%20D%5C)%20%7C%0A%0AThe%20ODE's%20logistic%20term%20cannot%20be%20used%20as%20one%20birth%20rate%3A%20it%20becomes%20negative%20above%20%5C(K%5C).%20Splitting%20it%20into%20births%20and%20crowding%20deaths%20gives%20nonnegative%20event%20rates%20with%20the%20same%20conditional%20drift.%20This%20is%20**one**%20stochastic%20model%20consistent%20with%20the%20ODE%2C%20not%20a%20unique%20consequence%20of%20it.%20The%20total-clock%20and%20weighted-event%20procedure%20is%20Gillespie's%20%5Bdirect%20method%5D(https%3A%2F%2Fwww.ma.imperial.ac.uk%2F~nsjones%2Fgillespie_1977.pdf).%0A%22%22%22)
ewan_obsidian_ready%0Adef%20panda_event_rates(W%2C%20D%2C%20beta)%3A%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20mu_w%20*%20W%2C%20mu_w%20*%20W%20*%20W%20%2F%20K_w%2C%20nu_w%20*%20W%2C%20beta%20*%20W%2C%0A%20%20%20%20%20%20%20%20mu_d%20*%20D%2C%20mu_d%20*%20D%20*%20D%20%2F%20K_d%2C%20nu_d%20*%20D%2C%0A%20%20%20%20)%0A%0A%0Adef%20simulate_panda_events(beta%2C%20T%2C%20seed)%3A%0A%20%20%20%20if%20W0%20!%3D%20round(W0)%20or%20D0%20!%3D%20round(D0)%3A%0A%20%20%20%20%20%20%20%20raise%20ValueError(%22Event%20simulation%20requires%20integer%20initial%20populations.%22)%0A%20%20%20%20W%2C%20D%20%3D%20int(W0)%2C%20int(D0)%0A%20%20%20%20rng%20%3D%20np.random.default_rng(seed)%0A%20%20%20%20t%20%3D%200.0%0A%20%20%20%20event_times%2C%20wild%2C%20domestic%20%3D%20%5Bt%5D%2C%20%5BW%5D%2C%20%5BD%5D%0A%20%20%20%20while%20t%20%3C%20T%3A%0A%20%20%20%20%20%20%20%20rates%20%3D%20panda_event_rates(W%2C%20D%2C%20beta)%0A%20%20%20%20%20%20%20%20total%20%3D%20sum(rates)%0A%20%20%20%20%20%20%20%20if%20total%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20next_t%20%3D%20t%20%2B%20rng.exponential(1%20%2F%20total)%0A%20%20%20%20%20%20%20%20if%20next_t%20%3E%20T%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20draw%20%3D%20rng.random()%20*%20total%0A%20%20%20%20%20%20%20%20for%20event%2C%20rate%20in%20enumerate(rates)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20draw%20-%3D%20rate%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20draw%20%3C%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20if%20event%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20W%20%2B%3D%201%0A%20%20%20%20%20%20%20%20elif%20event%20in%20(1%2C%202)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20W%20-%3D%201%0A%20%20%20%20%20%20%20%20elif%20event%20%3D%3D%203%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20W%2C%20D%20%3D%20W%20-%201%2C%20D%20%2B%201%0A%20%20%20%20%20%20%20%20elif%20event%20%3D%3D%204%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20D%20%2B%3D%201%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20D%20-%3D%201%0A%20%20%20%20%20%20%20%20t%20%3D%20next_t%0A%20%20%20%20%20%20%20%20event_times.append(t)%0A%20%20%20%20%20%20%20%20wild.append(W)%0A%20%20%20%20%20%20%20%20domestic.append(D)%0A%20%20%20%20%20%20%20%20if%20len(event_times)%20%3E%20100_000%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20raise%20RuntimeError(%22Event%20limit%20reached%3B%20shorten%20T%20or%20reduce%20rates.%22)%0A%20%20%20%20if%20event_times%5B-1%5D%20%3C%20T%3A%0A%20%20%20%20%20%20%20%20event_times.append(float(T))%0A%20%20%20%20%20%20%20%20wild.append(W)%0A%20%20%20%20%20%20%20%20domestic.append(D)%0A%20%20%20%20return%20np.array(event_times)%2C%20np.array(wild)%2C%20np.array(domestic)
ewan_obsidian_ready%0Astochastic_seed%20%3D%20mo.ui.slider(%0A%20%20%20%20start%3D0%2C%20stop%3D99%2C%20step%3D1%2C%20value%3D7%2C%20label%3D%22Random%20seed%22%2C%20show_value%3DTrue%0A)%0Astochastic_seed
ewan_obsidian_ready%0Apanda_sample_paths%20%3D%20%5B%0A%20%20%20%20simulate_panda_events(capture_rate.value%2C%20horizon.value%2C%20stochastic_seed.value%20%2B%20run)%0A%20%20%20%20for%20run%20in%20range(6)%0A%5D
ewan_obsidian_ready%0A_fig%20%3D%20go.Figure()%0Afor%20_run%2C%20(_t%2C%20_w%2C%20_d)%20in%20enumerate(panda_sample_paths)%3A%0A%20%20%20%20_fig.add_scatter(%0A%20%20%20%20%20%20%20%20x%3D_t%2C%20y%3D_d%2C%20mode%3D%22lines%22%2C%20line_shape%3D%22hv%22%2C%0A%20%20%20%20%20%20%20%20line%3Ddict(color%3D%22%2356706b%22%2C%20width%3D1.4)%2C%20opacity%3D0.48%2C%0A%20%20%20%20%20%20%20%20name%3D%22Event%20paths%22%2C%20showlegend%3D_run%20%3D%3D%200%2C%0A%20%20%20%20)%0A_fig.add_scatter(%0A%20%20%20%20x%3Dtimes%2C%20y%3Dtrajectory%5B%3A%2C%201%5D%2C%20mode%3D%22lines%22%2C%0A%20%20%20%20line%3Ddict(color%3D%22%23bf6159%22%2C%20width%3D3)%2C%20name%3D%22ODE%20(Euler)%22%2C%0A)%0A_fig.update_layout(%0A%20%20%20%20height%3D350%2C%20xaxis_title%3D%22Time%22%2C%20yaxis_title%3D%22Domestic%20pandas%20D%22%2C%0A%20%20%20%20margin%3Ddict(l%3D45%2C%20r%3D15%2C%20t%3D15%2C%20b%3D40)%2C%0A%20%20%20%20legend%3Ddict(orientation%3D%22h%22%2C%20y%3D-0.28)%2C%20uirevision%3D%22panda-events%22%2C%0A)%0A_fig
ewan_obsidian_ready%0Amo.md(fr%22%22%22%0AThe%20six%20paths%20use%20the%20same%20initial%20state%20and%20capture%20rate.%20At%20%5C(T%3D%7Bhorizon.value%3Ag%7D%5C)%2C%20their%20zoo%20populations%20range%20from%20**%7Bmin(path%5B2%5D%5B-1%5D%20for%20path%20in%20panda_sample_paths)%7D**%20to%20**%7Bmax(path%5B2%5D%5B-1%5D%20for%20path%20in%20panda_sample_paths)%7D**%3B%20Euler%20gives%20**%7Btrajectory%5B-1%2C%201%5D%3A.1f%7D**.%20These%20are%20simulated%20paths%2C%20not%20recorded%20panda%20counts.%0A%0A%23%23%23%20What%20should%20agree%3F%0A%0AThe%20event%20model%20has%20%5C(%5Cmathbb%7B%7BE%7D%7D%5B%5CDelta%20W%5Cmid%20W%2CD%5D%2F%5Cmathrm%7B%7Bd%7D%7Dt%3D%5Cdot%20W%5C)%20and%20%5C(%5Cmathbb%7B%7BE%7D%7D%5B%5CDelta%20D%5Cmid%20W%2CD%5D%2F%5Cmathrm%7B%7Bd%7D%7Dt%3D%5Cdot%20D%5C).%20That%20matches%20the%20ODE's%20**conditional%20drift**.%20It%20does%20not%20imply%20that%20the%20ODE%20trajectory%20equals%20the%20average%20of%20stochastic%20runs%3A%20%5C(%5Cmathbb%7B%7BE%7D%7D%5BW%5E2%5D%5C)%20generally%20differs%20from%20%5C(%5Cmathbb%7B%7BE%7D%7D%5BW%5D%5E2%5C)%2C%20and%20extinction%20is%20absorbing.%0A%0AThe%20prediction%20%5C(%5Cbeta%5E*%3D0.25%5C)%20maximizes%20the%20deterministic%20long-run%20domestic%20fixed%20point%20for%20the%20original%20rates.%20A%20finite-time%20stochastic%20objective%20needs%20repeated%20runs%20at%20each%20%5C(%5Cbeta%5C).%0A%0A*Lecture%20source%3A%20Aletheia%20ASR%2C%202026-09-22%2014%3A56%E2%80%9315%3A29%20EDT%3B%20turn%20IDs%203379d1b5-fe6a-5564-b645-21d1b6805ff1%3A82f9a34e272833ee714aa66dc9793737bd2d35da4536733f20927bd3676e4d46%3A0%20and%209c1205ec-1192-51ed-abf9-89177e34321d%3Ab35472fedda1d16f118a327b31074d6fa5fad8cc79c980fe50bf3a4f26912bff%3A1.%20Words%20were%20not%20listening-verified.*%0A%22%22%22)
ewan_obsidian_ready%0Amo.md(r%22%22%22%0A%23%23%20Test%20the%20capture%20prediction%0A%0ACompare%20final%20zoo%20size%20%5C(D(T)%5C)%20at%20several%20capture%20rates%20while%20holding%20the%20initial%20state%2C%20horizon%2C%20and%20rate%20parameters%20fixed.%20The%20dots%20below%20are%20individual%20simulated%20outcomes%3B%20the%20line%20joins%20their%20sample%20means.%20The%20ODE%20curve%20is%20the%20deterministic%20calculation%20already%20shown%20above.%20With%20only%20eight%20runs%20per%20rate%2C%20the%20means%20are%20exploratory.%0A%22%22%22)
ewan_obsidian_ready%0Arun_capture_sweep%20%3D%20mo.ui.run_button(label%3D%22Run%20stochastic%20%CE%B2%20sweep%22)%0Arun_capture_sweep
ewan_obsidian_ready%0Amo.stop(not%20run_capture_sweep.value%2C%20mo.md(%22Run%20the%20sweep%20to%20sample%20final%20zoo%20populations.%22))%0Astochastic_betas%20%3D%20np.array(%5B0.0%2C%200.1%2C%200.2%2C%200.25%2C%200.3%2C%200.4%2C%200.5%5D)%0Astochastic_final_D%20%3D%20np.array(%5B%0A%20%20%20%20%5Bsimulate_panda_events(float(beta)%2C%20horizon.value%2C%20stochastic_seed.value%20%2B%201000%20*%20j%20%2B%20run)%5B2%5D%5B-1%5D%0A%20%20%20%20%20for%20run%20in%20range(8)%5D%0A%20%20%20%20for%20j%2C%20beta%20in%20enumerate(stochastic_betas)%0A%5D)%0Astochastic_mean_D%20%3D%20stochastic_final_D.mean(axis%3D1)
ewan_obsidian_ready%0A_fig%20%3D%20go.Figure()%0Afor%20_j%2C%20_beta%20in%20enumerate(stochastic_betas)%3A%0A%20%20%20%20_fig.add_scatter(%0A%20%20%20%20%20%20%20%20x%3D%5B_beta%5D%20*%208%2C%20y%3Dstochastic_final_D%5B_j%5D%2C%20mode%3D%22markers%22%2C%0A%20%20%20%20%20%20%20%20marker%3Ddict(color%3D%22%2356706b%22%2C%20size%3D6%2C%20opacity%3D0.45)%2C%0A%20%20%20%20%20%20%20%20name%3D%22Individual%20runs%22%2C%20showlegend%3D_j%20%3D%3D%200%2C%0A%20%20%20%20)%0A_fig.add_scatter(%0A%20%20%20%20x%3Dstochastic_betas%2C%20y%3Dstochastic_mean_D%2C%20mode%3D%22lines%2Bmarkers%22%2C%0A%20%20%20%20line%3Ddict(color%3D%22%2356706b%22%2C%20width%3D2)%2C%20name%3D%22Mean%20of%208%20runs%22%2C%0A)%0A_fig.add_scatter(%0A%20%20%20%20x%3Dbetas%2C%20y%3Dfinal_D%2C%20mode%3D%22lines%22%2C%0A%20%20%20%20line%3Ddict(color%3D%22%23bf6159%22%2C%20width%3D2)%2C%20name%3D%22ODE%20D(T)%22%2C%0A)%0A_fig.add_vline(x%3Dbeta_star%2C%20line_dash%3D%22dash%22%2C%20line_color%3D%22%239a8f82%22)%0A_fig.update_layout(%0A%20%20%20%20height%3D350%2C%20xaxis_title%3D%22Capture%20rate%20%CE%B2%22%2C%20yaxis_title%3D%22Domestic%20pandas%20at%20T%22%2C%0A%20%20%20%20margin%3Ddict(l%3D45%2C%20r%3D15%2C%20t%3D15%2C%20b%3D40)%2C%0A%20%20%20%20legend%3Ddict(orientation%3D%22h%22%2C%20y%3D-0.28)%2C%20uirevision%3D%22stochastic-beta-sweep%22%2C%0A)%0A_fig
ewan_obsidian_ready%0A_peak%20%3D%20int(np.argmax(stochastic_mean_D))%0Amo.md(f%22%22%22At%20these%20settings%2C%20the%20largest%20sampled%20mean%20is%20**%7Bstochastic_mean_D%5B_peak%5D%3A.2f%7D%20pandas%20at%20%CE%B2%3D%7Bstochastic_betas%5B_peak%5D%3A.2f%7D**%20(8%20runs%20per%20rate).%20The%20deterministic%20long-run%20prediction%20is%20%CE%B2*%3D%7Bbeta_star%3A.2f%7D.%20This%20small%20finite-time%20sample%20does%20not%20establish%20a%20different%20optimum.%22%22%22)
ewan_obsidian_ready%0Amo.md(r%22%22%22%0A%23%23%20Numerical%20integration%20from%20Taylor%0A%0AThe%20ODE%20specifies%20a%20slope%20%5C(%5Cdot%7B%5Cmathbf%7Bx%7D%7D%3Df(t%2C%5Cmathbf%7Bx%7D)%5C).%20Over%20one%20step%2C%0A%0A%5C%5B%0A%5Cmathbf%7Bx%7D(t%2Bh)%3D%5Cmathbf%7Bx%7D(t)%2Bh%20f(t%2C%5Cmathbf%7Bx%7D(t))%0A%2B%5Cfrac%7Bh%5E2%7D%7B2%7D%5Cddot%7B%5Cmathbf%7Bx%7D%7D(t)%2BO(h%5E3).%0A%5C%5D%0A%0AEuler%20keeps%20the%20first%20slope%20and%20drops%20the%20curvature%20term%2C%20giving%20**local%20error**%20%5C(O(h%5E2)%5C)%20for%20a%20smooth%20solution.%20Over%20a%20fixed%20time%20interval%2C%20about%20%5C(T%2Fh%5C)%20steps%20accumulate%20into%20**global%20error**%20%5C(O(h)%5C)%20under%20the%20usual%20stability%20assumptions.%20Reducing%20%5C(h%5C)%20improves%20this%20**ODE%20approximation**.%20It%20does%20not%20turn%20an%20ODE%20trajectory%20into%20a%20stochastic%20sample%20path%20or%20estimate%20extinction%20probability.%0A%0AHigher%20derivatives%20are%20not%20supplied%20directly%20by%20the%20model%2C%20though%20they%20can%20be%20derived%20from%20a%20smooth%20%5C(f%5C).%20Other%20integrators%20use%20extra%20evaluations%20of%20%5C(f%5C)%20to%20capture%20more%20of%20the%20curve%20within%20a%20step.%0A%0A*Lecture%20source%3A%20Aletheia%20ASR%2C%202026-09-22%2015%3A39%E2%80%9315%3A43%20EDT%3B%20turn%20IDs%208833aaa1-f440-5bce-8363-9fd3b14f64fd%3Aa8815b127af63029065fda9b7b73586b3ce12c94613a70cbc690500d79c1edcd%3A0%20and%20735e750d-2825-5f28-a7ba-49160d101fe6%3A9ac2e9991864ea684307c05f3a733d07b4f76d21b64b1dcfdff77ee927f6ca03%3A0.%20Words%20were%20not%20listening-verified.*%0A%22%22%22)
ewan_obsidian_ready%0Amo.md(r%22%22%22%0A%23%23%20SIS%3A%20fixed%20points%0A%0AResuming%20the%20%5B%5Bsis_model%7CSIS%20model%5D%5D%2C%20we%20have%20%24S%2BI%3DN%24%2C%20so%20there%20is%20only%20**one%20degree%20of%20freedom**%3A%0A%0A%24%24%5Cdot%20I%3D%5Cbeta(N-I)I-%5Calpha%20I%3DI%5B%5Cbeta(N-I)-%5Calpha%5D.%24%24%0A%0AFor%20a%20continuous%20system%2C%20a%20%5B%5BFixed%20Point%20Classification%7Cfixed%20point%5D%5D%20satisfies%20%24%5Cdot%20I%3D0%24.%20This%20gives%0A%0A%24%24I_1%3D0%2C%5Cqquad%20I_2%3DN-%5Cfrac%7B%5Calpha%7D%7B%5Cbeta%7D%5Cquad(%5Cbeta%3E0).%24%24%0A%0AThe%20subscripts%20label%20the%20two%20solutions%2C%20**not%20time%20steps**.%20%24I_1%24%20has%20no%20infection.%20At%20%24I_2%24%2C%20infection%20and%20recovery%20still%20happen%2C%20but%20their%20rates%20balance.%0A%0A%23%23%23%20Phase%20space%0A%0APhase%20space%20is%20the%20space%20of%20possible%20states.%20We%20can%20draw%20%24(S%2CI)%24%20on%20two%20axes%2C%20but%20the%20system%20is%20stuck%20on%20%24S%2BI%3DN%24%2C%20with%20%240%5Cleq%20I%5Cleq%20N%24.%20The%20rest%20of%20the%20plane%20is%20not%20available%20to%20it.%0A%0ATo%20remove%20redundant%20parameters%2C%20let%20%24i%3DI%2FN%24%2C%20%24%5Ctau%3D%5Calpha%20t%24%2C%20and%20%24R%3D%5Cbeta%20N%2F%5Calpha%24%20(%24%5Calpha%3E0%24)%3A%0A%0A%24%24%5Cfrac%7Bdi%7D%7Bd%5Ctau%7D%3Di%5BR(1-i)-1%5D%2C%5Cqquad%20i_1%3D0%2C%5Cquad%20i_2%3D1-%5Cfrac1R.%24%24%0A%0AThe%20threshold%20is%20%24R%3D1%24%2C%20or%20%24%5Cbeta_c%3D%5Calpha%2FN%24.%20Change%20%24R%24%20across%201%20and%20compare%20the%20direction%20of%20motion%20with%20the%20fixed-point%20branches.%20Changing%20%24i_0%24%20moves%20the%20starting%20point%20on%20the%20same%20phase-space%20line.%0A%22%22%22)
ewan_obsidian_ready%0Asis_R%20%3D%20mo.ui.slider(start%3D0%2Cstop%3D3%2Cstep%3D.05%2Cvalue%3D1.5%2Clabel%3D%22R%20%3D%20%CE%B2N%2F%CE%B1%22%2Cshow_value%3DTrue)%0Asis_initial%20%3D%20mo.ui.slider(start%3D0%2Cstop%3D1%2Cstep%3D.01%2Cvalue%3D.1%2Clabel%3D%22Initial%20infected%20fraction%20i%E2%82%80%22%2Cshow_value%3DTrue)%0Amo.hstack(%5Bsis_R%2Csis_initial%5D)
ewan_obsidian_ready%0Adef%20sis_rhs(i%2C%20R)%3A%0A%20%20%20%20return%20i%20*%20(R%20*%20(1-i)%20-%201)%0A%0A%0Adef%20sis_exact(t%2C%20i0%2C%20R)%3A%0A%20%20%20%20if%20i0%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20return%20np.zeros_like(t)%0A%20%20%20%20a%20%3D%20R-1%0A%20%20%20%20if%20abs(a)%3C1e-12%3A%0A%20%20%20%20%20%20%20%20return%20i0%2F(1%2Bi0*t)%0A%20%20%20%20exp_at%20%3D%20np.exp(a*t)%0A%20%20%20%20return%20i0*exp_at%2F(1%2B(R*i0%2Fa)*np.expm1(a*t))%0A%0Asis_time%20%3D%20np.linspace(0%2C30%2C601)%0Asis_path%20%3D%20sis_exact(sis_time%2Csis_initial.value%2Csis_R.value)%0Asis_branch%20%3D%20None%20if%20sis_R.value%20%3D%3D%200%20else%201-1%2Fsis_R.value%0Asis_grid%20%3D%20np.linspace(0%2C1%2C201)%0Asis_velocity%20%3D%20sis_rhs(sis_grid%2Csis_R.value)
ewan_obsidian_ready%0A_r%3Dsis_R.value%0A_i0%3Dsis_initial.value%0A_fig%3Dmake_subplots(rows%3D1%2Ccols%3D3%2Csubplot_titles%3D(%22Phase%20space%22%2C%20%22Slope%20along%20the%20line%22%2C%20%22Bifurcation%20diagram%22))%0A_fig.add_trace(go.Scatter(x%3D%5B1%2C0%5D%2Cy%3D%5B0%2C1%5D%2Cmode%3D%22lines%22%2Cline%3Ddict(color%3D%22%239a8f82%22)%2Cshowlegend%3DFalse)%2C1%2C1)%0A_fig.add_trace(go.Scatter(x%3D1-sis_path%2Cy%3Dsis_path%2Cline%3Ddict(color%3D%22%2356706b%22%2Cwidth%3D4)%2Cshowlegend%3DFalse)%2C1%2C1)%0A_fig.add_trace(go.Scatter(x%3D%5B1-_i0%5D%2Cy%3D%5B_i0%5D%2Cmode%3D%22markers%22%2Cmarker%3Ddict(symbol%3D%22diamond%22%2Csize%3D10%2Ccolor%3D%22%23cc9e54%22)%2Cname%3D%22Initial%20state%22)%2C1%2C1)%0Afor%20_i%20in%20np.linspace(.08%2C.92%2C8)%3A%0A%20%20%20%20_v%3Dfloat(sis_rhs(_i%2C_r))%0A%20%20%20%20if%20abs(_v)%3E1e-5%3A%0A%20%20%20%20%20%20%20%20_d%3D.035*np.sign(_v)%0A%20%20%20%20%20%20%20%20_fig.add_annotation(x%3D1-_i-_d%2Cy%3D_i%2B_d%2Cax%3D1-_i%2B_d%2Cay%3D_i-_d%2Cxref%3D%22x%22%2Cyref%3D%22y%22%2Caxref%3D%22x%22%2Cayref%3D%22y%22%2Cshowarrow%3DTrue%2Carrowhead%3D2%2Carrowcolor%3D%22%234a4238%22%2Crow%3D1%2Ccol%3D1)%0A_fig.add_trace(go.Scatter(x%3Dsis_grid%2Cy%3Dsis_velocity%2Cline%3Ddict(color%3D%22%2356706b%22)%2Cshowlegend%3DFalse)%2C1%2C2)%0A_fig.add_hline(y%3D0%2Cline_color%3D%22%239a8f82%22%2Crow%3D1%2Ccol%3D2)%0A_fig.add_trace(go.Scatter(x%3D%5B_i0%5D%2Cy%3D%5Bsis_rhs(_i0%2C_r)%5D%2Cmode%3D%22markers%22%2Cmarker%3Ddict(symbol%3D%22diamond%22%2Csize%3D9%2Ccolor%3D%22%23cc9e54%22)%2Cshowlegend%3DFalse)%2C1%2C2)%0Afor%20_lo%2C_hi%2C_dash%2C_name%20in%20%5B(0%2C1%2C%22solid%22%2C%22Attracting%22)%2C(1%2C3%2C%22dash%22%2C%22Repelling%22)%5D%3A%0A%20%20%20%20_rs%3Dnp.linspace(_lo%2C_hi%2C151)%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D_rs%2Cy%3Dnp.zeros_like(_rs)%2Cline%3Ddict(color%3D%22%23728c99%22%2Cdash%3D_dash)%2Cname%3D_name)%2C1%2C3)%0A_rs%3Dnp.linspace(.25%2C1%2C151)%0A_fig.add_trace(go.Scatter(x%3D_rs%2Cy%3D1-1%2F_rs%2Cline%3Ddict(color%3D%22%23a67c6d%22%2Cdash%3D%22dash%22)%2Cname%3D%22Nonphysical%20branch%22)%2C1%2C3)%0A_rs%3Dnp.linspace(1%2C3%2C201)%0A_fig.add_trace(go.Scatter(x%3D_rs%2Cy%3D1-1%2F_rs%2Cline%3Ddict(color%3D%22%2356706b%22)%2Cname%3D%22Endemic%20branch%22)%2C1%2C3)%0A_fig.add_hrect(y0%3D-1%2Cy1%3D0%2Cfillcolor%3D%22%23e6dfd6%22%2Copacity%3D.45%2Cline_width%3D0%2Crow%3D1%2Ccol%3D3)%0A_fig.add_vline(x%3D_r%2Cline_color%3D%22%232d2520%22%2Crow%3D1%2Ccol%3D3)%0Afor%20_p%2C_stable%20in%20%5B(0%2C_r%3C1)%5D%2B(%5B(sis_branch%2C_r%3E1)%5D%20if%20sis_branch%20is%20not%20None%20else%20%5B%5D)%3A%0A%20%20%20%20_symbol%3D%22circle%22%20if%20_stable%20else%20%22circle-open%22%0A%20%20%20%20if%20_r%3D%3D1%3A%20_symbol%3D%22diamond%22%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D%5B_r%5D%2Cy%3D%5B_p%5D%2Cmode%3D%22markers%22%2Cmarker%3Ddict(symbol%3D_symbol%2Csize%3D10%2Ccolor%3D%22%232d2520%22)%2Cshowlegend%3DFalse)%2C1%2C3)%0A%20%20%20%20if%200%3C%3D_p%3C%3D1%3A%0A%20%20%20%20%20%20%20%20_fig.add_trace(go.Scatter(x%3D%5B1-_p%5D%2Cy%3D%5B_p%5D%2Cmode%3D%22markers%22%2Cmarker%3Ddict(symbol%3D_symbol%2Csize%3D11%2Ccolor%3D%22%232d2520%22)%2Cshowlegend%3DFalse)%2C1%2C1)%0A%20%20%20%20%20%20%20%20_fig.add_trace(go.Scatter(x%3D%5B_p%5D%2Cy%3D%5B0%5D%2Cmode%3D%22markers%22%2Cmarker%3Ddict(symbol%3D_symbol%2Csize%3D10%2Ccolor%3D%22%232d2520%22)%2Cshowlegend%3DFalse)%2C1%2C2)%0A_fig.update_xaxes(title_text%3D%22s%20%3D%20S%2FN%22%2Crange%3D%5B-.05%2C1.05%5D%2Crow%3D1%2Ccol%3D1)%0A_fig.update_yaxes(title_text%3D%22i%20%3D%20I%2FN%22%2Crange%3D%5B-.05%2C1.05%5D%2Cscaleanchor%3D%22x%22%2Cscaleratio%3D1%2Crow%3D1%2Ccol%3D1)%0A_fig.update_xaxes(title_text%3D%22i%22%2Crange%3D%5B0%2C1%5D%2Crow%3D1%2Ccol%3D2)%0A_fig.update_yaxes(title_text%3D%22di%2Fd%CF%84%22%2Crange%3D%5B-1.05%2C.4%5D%2Crow%3D1%2Ccol%3D2)%0A_fig.update_xaxes(title_text%3D%22R%20%3D%20%CE%B2N%2F%CE%B1%22%2Crange%3D%5B0%2C3%5D%2Crow%3D1%2Ccol%3D3)%0A_fig.update_yaxes(title_text%3D%22Fixed%20point%20i*%22%2Crange%3D%5B-1%2C1%5D%2Crow%3D1%2Ccol%3D3)%0A_fig.update_layout(height%3D380%2Cmargin%3Ddict(l%3D45%2Cr%3D15%2Ct%3D40%2Cb%3D40)%2Clegend%3Ddict(orientation%3D%22h%22%2Cy%3D-.25)%2Cuirevision%3D%22sis-geometry%22)%0A_fig
ewan_obsidian_ready%0Amo.md(r%22%22%22%0A%23%23%23%20Bifurcation%20diagram%0A%0AA%20bifurcation%20diagram%20puts%20the%20**parameter**%20on%20one%20axis%20and%20the%20**fixed%20points**%20on%20the%20other.%20We%20are%20comparing%20different%20systems%2C%20rather%20than%20following%20one%20trajectory%20through%20time.%20Compare%20%5B%5BLogistic%20Map%23Plotting%20Bifurcations%5D%5D.%0A%0AFor%20%24g(i)%3Di%5BR(1-i)-1%5D%24%3A%0A%0A%24%24g'(0)%3DR-1%2C%5Cqquad%20g'(i_2)%3D1-R.%24%24%0A%0A-%20%24R%3C1%24%3A%20zero%20is%20%5B%5BAttracting%20fixed%20point%7Cattracting%5D%5D.%20The%20other%20solution%20is%20negative%2C%20so%20it%20is%20outside%20the%20population%20model.%0A-%20%24R%3E1%24%3A%20zero%20is%20%5B%5BRepelling%20fixed%20point%7Crepelling%5D%5D%2C%20and%20the%20positive%20solution%20attracts%20nearby%20states.%0A-%20%24R%3D1%24%3A%20the%20branches%20meet.%20Here%20%24i'%3D-i%5E2%24%2C%20so%20positive%20initial%20states%20still%20approach%20zero%2C%20but%20only%20algebraically.%0A%0AThis%20exchange%20of%20stability%20is%20a%20**transcritical%20bifurcation**.%20Solid%20branches%20attract%3B%20dashed%20branches%20repel.%20The%20diamond%20at%20the%20crossing%20marks%20the%20nonhyperbolic%20case.%20Starting%20*exactly*%20at%20zero%20stays%20there%20even%20above%20threshold.%0A%0AFor%20flows%20the%20sign%20of%20%24g'%24%20gives%20local%20stability.%20For%20the%20discrete%20maps%20in%20%5B%5BFixed%20Point%20Classification%5D%5D%2C%20the%20condition%20was%20%24%7Cf'%7C%3C1%24.%20Related%3A%20%5B%5BLinearization%20and%20the%20Jacobian%5D%5D.%0A%0A%23%23%23%20Why%20can't%20it%20oscillate%3F%0A%0AAt%20any%20given%20%24i%24%2C%20an%20autonomous%20equation%20gives%20one%20value%20of%20%24i'%24.%20It%20cannot%20point%20right%20now%20and%20left%20later%20at%20the%20same%20point.%20Under%20uniqueness%2C%20a%20trajectory%20also%20cannot%20cross%20a%20fixed%20point.%20So%20this%20one-dimensional%20flow%20cannot%20have%20a%20nonconstant%20periodic%20orbit.%0A%0ADiscrete%20maps%20can%20jump%20over%20fixed%20points.%20Two-dimensional%20flows%20can%20move%20around%20them%20and%20form%20a%20%5B%5BLimit%20Cycle%5D%5D.%20If%20a%20rate%20varies%20with%20time%2C%20as%20in%20the%20class's%20seasonal-birth%20example%2C%20time%20(or%20seasonal%20phase)%20is%20additional%20information%20needed%20to%20specify%20the%20dynamics.%0A%22%22%22)
ewan_obsidian_ready%0Aeuler_h%20%3D%20mo.ui.slider(start%3D.05%2Cstop%3D2%2Cstep%3D.05%2Cvalue%3D.5%2Clabel%3D%22Euler%20step%20%CE%94%CF%84%22%2Cshow_value%3DTrue)%0Aeuler_h
ewan_obsidian_ready%0Aeuler_times%20%3D%20np.arange(0%2C30%2B1e-9%2Ceuler_h.value)%0Aeuler_values%20%3D%20np.full(len(euler_times)%2Cnp.nan)%0Aeuler_values%5B0%5D%20%3D%20sis_initial.value%0Afor%20_n%20in%20range(len(euler_times)-1)%3A%0A%20%20%20%20_next%20%3D%20euler_values%5B_n%5D%2Beuler_h.value*sis_rhs(euler_values%5B_n%5D%2Csis_R.value)%0A%20%20%20%20if%20not%20np.isfinite(_next)%20or%20abs(_next)%3E1e6%3A%0A%20%20%20%20%20%20%20%20break%0A%20%20%20%20euler_values%5B_n%2B1%5D%3D_next%0A_euler_fig%3Dgo.Figure()%0A_euler_fig.add_scatter(x%3Dsis_time%2Cy%3Dsis_path%2Cname%3D%22Continuous%20solution%22%2Cline%3Ddict(color%3D%22%2356706b%22))%0A_euler_fig.add_scatter(x%3Deuler_times%2Cy%3Deuler_values%2Cname%3D%22Euler%20steps%22%2Cmode%3D%22lines%2Bmarkers%22%2Cline%3Ddict(color%3D%22%23bf6159%22)%2Cmarker%3Ddict(size%3D4))%0A_euler_fig.update_layout(height%3D310%2Cxaxis_title%3D%22%CF%84%20%3D%20%CE%B1t%22%2Cyaxis_title%3D%22Infected%20fraction%20i%22%2Cmargin%3Ddict(l%3D45%2Cr%3D15%2Ct%3D15%2Cb%3D40)%2Cuirevision%3D%22euler-check%22)%0A_euler_fig.update_yaxes(range%3D%5B-.1%2C1.1%5D)%0A_euler_fig
ewan_obsidian_ready%0Amo.md(r%22%22%22%0AEuler%20is%20itself%20a%20discrete%20map.%20Near%20an%20attracting%20fixed%20point%20its%20multiplier%20is%20%241%2Bh%20g'(i%5E*)%24%2C%20so%20numerical%20stability%20needs%0A%0A%24%24%7C1%2Bh%20g'(i%5E*)%7C%3C1.%24%24%0A%0ATry%20%24R%3D3%24%2C%20%24i_0%3D0.1%24%2C%20and%20increase%20the%20step%20past%20%24h%3D1%24.%20The%20continuous%20solution%20still%20approaches%20its%20fixed%20point%3B%20Euler%20can%20oscillate%20or%20leave%20%24%5B0%2C1%5D%24.%20That%20behavior%20belongs%20to%20the%20approximation.%20Values%20are%20not%20clipped%20back%20into%20the%20population%20range.%0A%22%22%22)
ewan_obsidian_ready%0Amo.md(r%22%22%22%0A%23%23%0A%22%22%22)