import{_ as s,c as i,o as a,a4 as n}from"./chunks/framework.DpC1ZpOZ.js";const u=JSON.parse('{"title":"mbcp.mp_math.equation","description":"","frontmatter":{"title":"mbcp.mp_math.equation","lastUpdated":false},"headers":[],"relativePath":"zht/api/mp_math/equation.md","filePath":"zht/api/mp_math/equation.md"}'),t={name:"zht/api/mp_math/equation.md"},l=n(`

模組 mbcp.mp_math.equation

本模块定义了方程相关的类和函数以及一些常用的数学函数

class CurveEquation

method __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)

説明: 曲线方程。

變數説明:

源碼於GitHub上查看
python
def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc):
    self.x_func = x_func
    self.y_func = y_func
    self.z_func = z_func

method self () *t: Var => Point3 | tuple[Point3, ...]

説明: 计算曲线上的点。

變數説明:

返回: 目标点

源碼於GitHub上查看
python
def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]:
    if len(t) == 1:
        return Point3(self.x_func(t[0]), self.y_func(t[0]), self.z_func(t[0]))
    else:
        return tuple([Point3(x, y, z) for x, y, z in zip(self.x_func(t), self.y_func(t), self.z_func(t))])

func get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number = EPSILON) -> MultiVarsFunc

説明: 求N元函数一阶偏导函数。这玩意不太稳定,慎用。

WARNING

目前数学界对于一个函数的导函数并没有通解的说法,因此该函数的稳定性有待提升

變數説明:

返回: 偏导函数

抛出:

源碼於GitHub上查看
python
def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], epsilon: Number=EPSILON) -> MultiVarsFunc:
    if isinstance(var, int):

        def partial_derivative_func(*args: Var) -> Var:
            args_list_plus = list(args)
            args_list_plus[var] += epsilon
            args_list_minus = list(args)
            args_list_minus[var] -= epsilon
            return (func(*args_list_plus) - func(*args_list_minus)) / (2 * epsilon)
        return partial_derivative_func
    elif isinstance(var, tuple):

        def high_order_partial_derivative_func(*args: Var) -> Var:
            result_func = func
            for v in var:
                result_func = get_partial_derivative_func(result_func, v, epsilon)
            return result_func(*args)
        return high_order_partial_derivative_func
    else:
        raise ValueError('Invalid var type')
`,23),h=[l];function p(e,k,r,E,d,g){return a(),i("div",null,h)}const o=s(t,[["render",p]]);export{u as __pageData,o as default};