gpt4 book ai didi

c - 求解 C 中的超越方程

转载 作者:太空宇宙 更新时间:2023-11-04 07:28:57 29 4
gpt4 key购买 nike

我需要用 C 求解这个超越方程:

x = 2.0 - 0.5sen(x)

我试过这个:

double x, newx, delta;

x = 2.0 - 0.5;
newx = sin(x);
delta = fabs(newx * x);

printf("%f", delta);

这是正确的吗?

谢谢!

最佳答案

使用数值方法求解方程,例如 Newton's method或者(更容易使用,而且在实践中不会慢太多)secant method .对于最后一个,不要重写下一个 x 的表达式,这样写是为了避免舍入误差(接近根的问题)影响太大。

关于c - 求解 C 中的超越方程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15619413/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com