【问题标题】:Apache Commons Math: get derivate/integrate functionApache Commons Math:获取派生/积分函数
【发布时间】:2015-06-04 16:41:53
【问题描述】:

我正在使用多项式函数。我用下一种方式推导/集成我的函数f

// derivation ...
new PolynomialFunction(vector).value(x).getPartialDerivative(derivationOrder)
// integration ...
UnivariateIntegrator integrator = new IterativeLegendreGaussIntegrator(pointsNumber, relativeAccuracy, absoluteAccuracy, minIterations, maxIterations);
integrator.integrate(128, f, from, to);

但是如何在不指定实际值的情况下从函数f 获得推导/积分结果?

即导数 (8 + 3x + x^2) => 3 + 2x

【问题讨论】:

    标签: java apache-commons-math


    【解决方案1】:

    我不相信 Apache Math Commons Library 支持符号派生/集成。但是,如果您按照问题所暗示的那样使用多项式,那么这在计算上很容易。如果您将多项式表示为一个系数数组,就像 Apache 对其 PolynomialFunction 所做的那样,这将非常容易。

    导数:

    1. 将每个系数乘以其对应单项式的次数(恰好是系数的索引)。
    2. 去掉数组开头的0。

    整合:

    1. 将每个系数除以其对应单项式的次数 + 1(即 index+1)。
    2. 在数组的开头添加一个未确定的常量(除非您从 0 积分到您的变量,然后您可以将其设为 0)。

    为任意函数执行此操作变得更加困难,有时甚至是不可能的。有些程序在这方面非常擅长,例如 SageMath。我会查阅微积分文本以获取更多信息。希望对您有所帮助!

    【讨论】:

      【解决方案2】:

      对于多项式函数,您可以使用PolynomialFunction 类的polynomialDerivative 方法直接获得导数(作为多项式)。 Commons Math 用户指南的analysis 部分还描述了更通用的微分设置。

      【讨论】:

        猜你喜欢
        • 2015-06-29
        • 1970-01-01
        • 2011-07-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-18
        • 2013-02-24
        相关资源
        最近更新 更多