本文介绍了实数的幂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个有趣的运动,它说:实现一个函数x ^Ÿ使用Turbo Pascal的标准功能

I've come across an interesting exercise and it says: Implement a function x^y using standard functions of Turbo Pascal

有关整数变量,我可以使用循环,但我不明白如何与真正在这种情况下变量。

For integer variables I can use for loop but I cannot understand how to work with real variables in this case.

我一直在思考如何做到这一点使用的泰勒级数(不知道如何使用它幂),我还发现, X ^ÿ = EXP(Y *日志(X))但是只有 LN (自然对数)的标准功能......

I've been thinking about how to do this using Taylor series (can't understand how to use it for exponentiation) and I also found out that x^y = exp(y*log(x)) but there is only ln (natural logarithm) in standard functions...

PS  我不要求你写code:给我建议或链接或东西,这将有助于解决这一问题,请

PS I'm not asking you to write code: give me advise or link or something that will help to solve this problem, please.

推荐答案

日志(X)的公式是自然对数,因此可以使用

log(x) in your formula is natural logarithm, so you can use

x^y = exp(y*ln(x))

没有任何疑问。无论 EXP LN 是标准的Turbo Pascal功能

without any doubts. Both exp and ln are standard Turbo Pascal functions

(通式为x的X ^计算y = b ^(Y *基-B数)

(general formula is x^y = b^(y * base-b logarithm of x)

这篇关于实数的幂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 10:21