在没有幂函数的情况下计算for循环中的分数指数 [英] Calculate fractional exponent in for loop without power function

查看:113
本文介绍了在没有幂函数的情况下计算for循环中的分数指数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这方面的数学有些不稳定.有人知道我如何使用*/-+和for循环以外的数学函数来计算10 ^ 2.2之类的幂吗?我没有访问数学库的权限(并且不能导入/包含它),但是需要计算这些东西.嗯..也许我应该看看数学库是怎么做到的.

My maths in this area is a bit shaky. Does anybody know how I can calculate a power such as 10^2.2 using no maths functions other than */-+ and a for loop? I don't have access to a maths library (and can't import/include it), but need to calculate these things. Hmm.. maybe I should just look how the math library does it.

推荐答案

您可以计算日志&仅使用泰勒(或麦克劳林)级数展开的基本算术的指数.因此,您应该能够利用某些身份:

You can compute logs & exponentials using only basic arithmetic with a Taylor (or Maclaurin) series expansion. So, you should be able to take advantage of certain identities:

exp(ln(a)) = a
ln(a^b) = b*ln(a)
ln(1+x) = x - (x^2)/2 + (x^3)/3 - ... + ...
exp(x) = 1 + x + (x^2)/2 + ...

看看你能从这一切中得到什么...

See what you can make of all of this...

这篇关于在没有幂函数的情况下计算for循环中的分数指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆