如何写这个数学方程到c ++ [英] How to write this math equation into c++

查看:158
本文介绍了如何写这个数学方程到c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何写在C ++中给出的公式,我不能使用快捷方式。我必须编写代码长版本这是我到目前为止

I don't know how to write the formula given in C++ and I cant use short cuts. I have to write the code in long version this is what I have so far

        4x^3 + 8x^2 + 9x - 18
y = --------------------------
       |7 – x^3| + √(3x^2 + 18)

| 表示绝对值

它需要采用这种格式(这是我的书中的示例):

It needs to be in a format like this (this is an example from my book):

double y = ((-4.0 * pow(x, 3.0)) + (8.0 * pow(x, 2.0) - (9.0 * x) + 18.0)) / (abs(7.0 - pow(x, 3.0)) + (sqrt(3.0) * pow(x, 2.0) + 10.0)); 


推荐答案

您的解决方案非常接近。但是,如果我正确理解了你的方程,这应该是正确的。

Your solution is very nearly there. However, if I've understood your equation correctly this should be correct.

double y = (4.0 * pow(x, 3.0) + 8.0 * pow(x, 2.0) + 9.0 * x - 18.0) / (std::abs(7.0 - pow(x, 3.0)) + sqrt(3.0 * pow(x, 2.0) + 18));

这篇关于如何写这个数学方程到c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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