给定输出确定函数的输入(涉及微积分)

发布于 2024-09-26 18:17:10 字数 828 浏览 3 评论 0原文

我的微积分老师给了我们一个程序,使用梯形规则计算给定区间的定积分。我知道编程函数像算术函数一样接受输入并产生输出,但我不知道如何执行逆操作:在给定输出的情况下找到输入。

问题指出:

“使用具有不同增量数 n 的梯形规则来估计从 t=0 到 t=9 所经过的距离。找到一个数字 D,其梯形和在此限制的 0.01 个单位内 (468)当n>D时。”

我已经用计算器通过“即插即用”估计了极限,并且我知道使用常规代数函数,我可以轻松做到:

limit (468) = 带变量 x 的代数表达式 (然后求解 x)

但是,对于编程函数我将如何执行此操作? 如何确定给定输出的编程函数的输入?

我正在计算区间 0 之间多项式 (x^2+11x+28)/(x+4) 的定积分9. 我的计算器中的梯形规则函数使用给定数量的梯形 n 计算区间 0 和 9 之间的定积分。

总的来说,我想知道如何做到这一点:

求解 n: 第468章

我的 TI-83 上的 trapezoidal_rule(a, b, n) 代码:

Prompt A
Prompt B
Prompt N
(B-A)/N->D
0->S
A->X
Y1/2->S
For(K,1,N-1,1)
X+D->X
Y1+S->S
End
B->X
Y1/2+S->S
SD->I
Disp "INTEGRAL"
Disp I

因为我不熟悉这个语法,也不熟悉计算机算法,所以我希望有人能帮我把这个代码变成代数方程或点我朝着这样做的方向。

编辑:这不是我作业的一部分——只是求知欲

My Calculus teacher gave us a program on to calculate the definite integrals of a given interval using the trapezoidal rule. I know that programmed functions take an input and produce an output as arithmetic functions would but I don't know how to do the inverse: find the input given the output.

The problem states:

"Use the trapezoidal rule with varying numbers, n, of increments to estimate the distance traveled from t=0 to t=9. Find a number D for which the trapezoidal sum is within 0.01 unit of this limit (468) when n > D."

I've estimated the limit through "plug and chug" with the calculator and I know that with a regular algebraic function, I could easily do:

limit (468) = algebraic expression with variable x
(then solve for x)

However, how would I do this for a programmed function? How would I determine the input of a programmed function given output?

I am calculating the definite integral for the polynomial, (x^2+11x+28)/(x+4), between the interval 0 and 9. The trapezoidal rule function in my calculator calculates the definite integral between the interval 0 and 9 using a given number of trapezoids, n.

Overall, I want to know how to do this:

Solve for n:
468 = trapezoidal_rule(a = 0, b = 9, n);

The code for trapezoidal_rule(a, b, n) on my TI-83:

Prompt A
Prompt B
Prompt N
(B-A)/N->D
0->S
A->X
Y1/2->S
For(K,1,N-1,1)
X+D->X
Y1+S->S
End
B->X
Y1/2+S->S
SD->I
Disp "INTEGRAL"
Disp I

Because I'm not familiar with this syntax nor am I familiar with computer algorithms, I was hoping someone could help me turn this code into an algebraic equation or point me in the direction to do so.

Edit: This is not part of my homework—just intellectual curiosity

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一绘本一梦想 2024-10-03 18:17:10

多项式 (x^2+11x+28)/(x+4)

这等于 x+7。梯形规则应该为该函数给出完全正确的结果!我猜这实际上不是您正在使用的函数...

没有通用的方法可以根据函数的输出来确定其输入是什么。 (一方面,许多函数可以将多个不同的输入映射到同一输出。)

因此,当您将具有给定步数的梯形规则应用于给定函数时,有一个错误公式,您可以在此处使用该公式计算出你需要的 n 的值......但是(1)它并不是非常漂亮,并且(2)当你刚刚开始查看时,期望你做的事情似乎不是一个非常合理的事情梯形规则。我猜你的老师实际上只是想让你“即插即用”。

我不知道(见上文)您实际集成的函数是什么,但让我们假设它只是 x^2+11x+28。下面我将其称为 f(x)。这个从0到9的积分实际上是940.5。假设你把区间[0,9]分成n块。然后梯形规则给出: [f(0)/2 + f(1*9/n) + f(2*9/n) + ... + f((n-1)*9/n) + f(9)/2] * 9/n。

让我们将其分成 x^2、11x 和 28 的贡献。事实证明,梯形近似为后两者给出了完全正确的结果。 (练习:找出原因。)因此,从梯形规则得到的误差与从 f(x) = x^2 得到的误差完全相同。

x^2 从 0 到 9 的实际积分为 (9^3-0^3)/3 = 243。梯形近似为 [0/2 + 1^2+2^2+...+(n- 1)^2 + n^2/2] * (9/n)^2 * (9/n)。 (练习:找出原因。)连续平方和有一个标准公式:1^2 + ... + n^2 = n(n+1/2)(n+1)/3。所以我们对 x^2 积分的梯形近似是 (9/n)^3 乘以 [(n-1)(n-1/2)n/3 + n^2/2] = (9/n)^ 3 倍 [n^3/3+1/6] = 243 + (9/n)^3/6。

换句话说,这种情况下的误差正好是(9/n)^3/6 = (243/2) / n^3。

因此,例如,当 (243/2) / n^3 < 时,误差将小于 0.01。 0.01,与n^3>相同100*243/2 = 12150,当 n >= 23 时为真。

[编辑添加:我没有仔细检查我的任何代数或算术;可能会有小错误。我认为您感兴趣的是想法而不是具体数字。]

the polynomial, (x^2+11x+28)/(x+4)

This is equal to x+7. The trapezoidal rule should give exactly correct results for this function! I'm guessing that this isn't actually the function you're working with...

There is no general way to determine, given the output of a function, what its input was. (For one thing, many functions can map multiple different inputs to the same output.)

So, there is a formula for the error when you apply the trapezoidal rule with a given number of steps to a given function, and you could use that here to work out the value of n you need ... but (1) it's not terribly beautiful, and (2) it doesn't seem like a very reasonable thing to expect you to do when you're just starting to look at the trapezoidal rule. I'd guess that your teacher actually just wanted you to "plug and chug".

I don't know (see above) what function you're actually integrating, but let's pretend it's just x^2+11x+28. I'll call this f(x) below. The integral of this from 0 to 9 is actually 940.5. Suppose you divide the interval [0,9] into n pieces. Then the trapezoidal rule gives you: [f(0)/2 + f(1*9/n) + f(2*9/n) + ... + f((n-1)*9/n) + f(9)/2] * 9/n.

Let's separate this out into the contributions from x^2, from 11x, and from 28. It turns out that the trapezoidal approximation gives exactly the right result for the latter two. (Exercise: Work out why.) So the error you get from the trapezoidal rule is exactly the same as the error you'd have got from f(x) = x^2.

The actual integral of x^2 from 0 to 9 is (9^3-0^3)/3 = 243. The trapezoidal approximation is [0/2 + 1^2+2^2+...+(n-1)^2 + n^2/2] * (9/n)^2 * (9/n). (Exercise: work out why.) There's a standard formula for sums of consecutive squares: 1^2 + ... + n^2 = n(n+1/2)(n+1)/3. So our trapezoidal approximation to the integral of x^2 is (9/n)^3 times [(n-1)(n-1/2)n/3 + n^2/2] = (9/n)^3 times [n^3/3+1/6] = 243 + (9/n)^3/6.

In other words, the error in this case is exactly (9/n)^3/6 = (243/2) / n^3.

So, for instance, the error will be less than 0.01 when (243/2) / n^3 < 0.01, which is the same as n^3 > 100*243/2 = 12150, which is true when n >= 23.

[EDITED to add: I haven't checked any of my algebra or arithmetic carefully; there may be small errors. I take it what you're interested is the ideas rather than the specific numbers.]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文