pocketpy/modules/math/index.html
2026-02-22 13:54:07 +00:00

538 lines
40 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.12.0.825083596199">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.12.0">
<!-- Primary Meta Tags -->
<title>math | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="math | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="3.141592653589793">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/math/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/math/">
<meta property="og:title" content="math | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="3.141592653589793">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/math/">
<meta property="twitter:title" content="math | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="3.141592653589793">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link id="retype-favicon" rel="icon" href="../../static/logo.png" />
<link href="../../resources/css/retype.css?v=3.12.0.825083596199" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.12.0.825083596199" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.12.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.12.0.825083596199" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.8</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M10.303 16.652c-2.837-.344-4.835-2.385-4.835-5.028 0-1.074.387-2.235 1.031-3.008-.279-.709-.236-2.214.086-2.837.86-.107 2.02.344 2.708.967.816-.258 1.676-.386 2.728-.386 1.053 0 1.913.128 2.686.365.666-.602 1.848-1.053 2.708-.946.3.581.344 2.085.064 2.815.688.817 1.053 1.913 1.053 3.03 0 2.643-1.998 4.641-4.877 5.006.73.473 1.224 1.504 1.224 2.686v2.235c0 .644.537 1.01 1.182.752 3.889-1.483 6.94-5.372 6.94-10.185 0-6.081-4.942-11.044-11.022-11.044-6.081 0-10.98 4.963-10.98 11.044a10.84 10.84 0 0 0 7.112 10.206c.58.215 1.139-.172 1.139-.752v-1.719a2.768 2.768 0 0 1-1.032.215c-1.418 0-2.256-.773-2.857-2.213-.237-.58-.495-.924-.989-.988-.258-.022-.344-.129-.344-.258 0-.258.43-.451.86-.451.623 0 1.16.386 1.719 1.181.43.623.881.903 1.418.903.537 0 .881-.194 1.375-.688.365-.365.645-.687.903-.902Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input id="retype-filter-input-mock" class="w-full h-10 pl-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded-lg shadow-none md:text-sm hover:border-filter-border-hover focus:outline-none focus:border-filter-border-focus placeholder-filter-placeholder" type="text">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M10.303 16.652c-2.837-.344-4.835-2.385-4.835-5.028 0-1.074.387-2.235 1.031-3.008-.279-.709-.236-2.214.086-2.837.86-.107 2.02.344 2.708.967.816-.258 1.676-.386 2.728-.386 1.053 0 1.913.128 2.686.365.666-.602 1.848-1.053 2.708-.946.3.581.344 2.085.064 2.815.688.817 1.053 1.913 1.053 3.03 0 2.643-1.998 4.641-4.877 5.006.73.473 1.224 1.504 1.224 2.686v2.235c0 .644.537 1.01 1.182.752 3.889-1.483 6.94-5.372 6.94-10.185 0-6.081-4.942-11.044-11.022-11.044-6.081 0-10.98 4.963-10.98 11.044a10.84 10.84 0 0 0 7.112 10.206c.58.215 1.139-.172 1.139-.752v-1.719a2.768 2.768 0 0 1-1.032.215c-1.418 0-2.256-.773-2.857-2.213-.237-.58-.495-.924-.989-.988-.258-.022-.344-.129-.344-.258 0-.258.43-.451.86-.451.623 0 1.16.386 1.719 1.181.43.623.881.903 1.418.903.537 0 .881-.194 1.375-.688.365-.365.645-.687.903-.902Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="math" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#math">#</doc-anchor-trigger>
<span>math</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="mathpi">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathpi">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.pi</code></span>
</h3>
</doc-anchor-target>
<p>3.141592653589793</p>
<doc-anchor-target id="mathe">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathe">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.e</code></span>
</h3>
</doc-anchor-target>
<p>2.718281828459045</p>
<doc-anchor-target id="mathinf">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathinf">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.inf</code></span>
</h3>
</doc-anchor-target>
<p>The <code translate="no" v-pre>inf</code>.</p>
<doc-anchor-target id="mathnan">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathnan">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.nan</code></span>
</h3>
</doc-anchor-target>
<p>The <code translate="no" v-pre>nan</code>.</p>
<doc-anchor-target id="mathceilx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathceilx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.ceil(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the ceiling of <code translate="no" v-pre>x</code> as a float, the smallest integer value greater than or equal to <code translate="no" v-pre>x</code>.</p>
<doc-anchor-target id="mathfabsx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathfabsx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.fabs(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the absolute value of <code translate="no" v-pre>x</code>.</p>
<doc-anchor-target id="mathfloorx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathfloorx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.floor(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the floor of <code translate="no" v-pre>x</code> as a float, the largest integer value less than or equal to <code translate="no" v-pre>x</code>.</p>
<doc-anchor-target id="mathfsumiterable">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathfsumiterable">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.fsum(iterable)</code></span>
</h3>
</doc-anchor-target>
<p>Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">&gt;&gt;&gt; sum([0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1])
0.9999999999999999
&gt;&gt;&gt; fsum([0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1])
1.0</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="mathgcda-b">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathgcda-b">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.gcd(a, b)</code></span>
</h3>
</doc-anchor-target>
<p>Return the greatest common divisor of the integers <code translate="no" v-pre>a</code> and <code translate="no" v-pre>b</code>.</p>
<doc-anchor-target id="mathisfinitex">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathisfinitex">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.isfinite(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code translate="no" v-pre>True</code> if <code translate="no" v-pre>x</code> is neither an infinity nor a NaN, and <code translate="no" v-pre>False</code> otherwise.</p>
<doc-anchor-target id="mathisinfx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathisinfx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.isinf(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code translate="no" v-pre>True</code> if <code translate="no" v-pre>x</code> is a positive or negative infinity, and <code translate="no" v-pre>False</code> otherwise.</p>
<doc-anchor-target id="mathisnanx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathisnanx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.isnan(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code translate="no" v-pre>True</code> if <code translate="no" v-pre>x</code> is a NaN (not a number), and <code translate="no" v-pre>False</code> otherwise.</p>
<doc-anchor-target id="mathisclosea-b">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathisclosea-b">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.isclose(a, b)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code translate="no" v-pre>True</code> if the values <code translate="no" v-pre>a</code> and <code translate="no" v-pre>b</code> are close to each other and <code translate="no" v-pre>False</code> otherwise.</p>
<doc-anchor-target id="mathexpx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathexpx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.exp(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code translate="no" v-pre>e</code> raised to the power of <code translate="no" v-pre>x</code>.</p>
<doc-anchor-target id="mathlogx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathlogx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.log(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the natural logarithm of <code translate="no" v-pre>x</code> (to base <code translate="no" v-pre>e</code>).</p>
<doc-anchor-target id="mathlog2x">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathlog2x">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.log2(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the base-2 logarithm of <code translate="no" v-pre>x</code>. This is usually more accurate than <code translate="no" v-pre>log(x, 2)</code>.</p>
<doc-anchor-target id="mathlog10x">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathlog10x">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.log10(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the base-10 logarithm of <code translate="no" v-pre>x</code>. This is usually more accurate than <code translate="no" v-pre>log(x, 10)</code>.</p>
<doc-anchor-target id="mathpowx-y">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathpowx-y">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.pow(x, y)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code translate="no" v-pre>x</code> raised to the power <code translate="no" v-pre>y</code>.</p>
<doc-anchor-target id="mathsqrtx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathsqrtx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.sqrt(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the square root of <code translate="no" v-pre>x</code>.</p>
<doc-anchor-target id="mathacosx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathacosx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.acos(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the arc cosine of <code translate="no" v-pre>x</code>, in radians.</p>
<doc-anchor-target id="mathasinx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathasinx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.asin(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the arc sine of <code translate="no" v-pre>x</code>, in radians.</p>
<doc-anchor-target id="mathatanx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathatanx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.atan(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the arc tangent of <code translate="no" v-pre>x</code>, in radians.</p>
<doc-anchor-target id="mathatan2y-x">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathatan2y-x">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.atan2(y, x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code translate="no" v-pre>atan(y / x)</code>, in radians. The result is between <code translate="no" v-pre>-pi</code> and <code translate="no" v-pre>pi</code>. The vector in the plane from the origin to point <code translate="no" v-pre>(x, y)</code> makes this angle with the positive X axis. The point of <code translate="no" v-pre>atan2()</code> is that the signs of both inputs are known to it, so it can compute the correct quadrant for the angle. For example, <code translate="no" v-pre>atan(1)</code> and <code translate="no" v-pre>atan2(1, 1)</code> are both <code translate="no" v-pre>pi/4</code>, but <code translate="no" v-pre>atan2(-1, -1)</code> is <code translate="no" v-pre>-3*pi/4</code>.</p>
<doc-anchor-target id="mathcosx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathcosx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.cos(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the cosine of <code translate="no" v-pre>x</code> radians.</p>
<doc-anchor-target id="mathsinx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathsinx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.sin(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the sine of <code translate="no" v-pre>x</code> radians.</p>
<doc-anchor-target id="mathtanx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathtanx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.tan(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the tangent of <code translate="no" v-pre>x</code> radians.</p>
<doc-anchor-target id="mathdegreesx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathdegreesx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.degrees(x)</code></span>
</h3>
</doc-anchor-target>
<p>Convert angle <code translate="no" v-pre>x</code> from radians to degrees.</p>
<doc-anchor-target id="mathradiansx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathradiansx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.radians(x)</code></span>
</h3>
</doc-anchor-target>
<p>Convert angle <code translate="no" v-pre>x</code> from degrees to radians.</p>
<doc-anchor-target id="mathmodfx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathmodfx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.modf(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the fractional and integer parts of <code translate="no" v-pre>x</code>. Both results carry the sign of <code translate="no" v-pre>x</code> and are floats.</p>
<doc-anchor-target id="mathcopysignx-y">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathcopysignx-y">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.copysign(x, y)</code></span>
</h3>
</doc-anchor-target>
<p>Return a float with the magnitude (absolute value) of <code translate="no" v-pre>x</code> but the sign of <code translate="no" v-pre>y</code>.</p>
<doc-anchor-target id="mathfactorialx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathfactorialx">#</doc-anchor-trigger>
<span><code translate="no" v-pre>math.factorial(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code translate="no" v-pre>x</code> factorial as an integer.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/lz4/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">lz4</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/msgpack/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">msgpack</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link text-sm leading-relaxed"><p>© Copyright 2026 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "math", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>