标签: polynomial-math

C#数学计算无法正常工作

好的,所以我在这里执行一个烦人的数学计算,试图解决其中一个立方根.

现在,这是我的C#代码:

public void CubeCalculate()
{
    //Calculate discriminant

    double insideSquareRoot = (18 * cubicAValue * cubicBValue * cubicCValue * cubicDValue) + (-4 * (Math.Pow(cubicBValue, 3) * cubicDValue) + (Math.Pow(cubicBValue, 2) * Math.Pow(cubicCValue, 2)) + (-4 * cubicAValue * Math.Pow(cubicCValue, 3)) + (-27 * Math.Pow(cubicAValue, 2) * Math.Pow(cubicDValue, 2)));

    if (insideSquareRoot < 0)
    {
        //One real solution, two imaginary
        double onecuberootradical1 = (1 / 2) * (((2 * Math.Pow(cubicBValue, 3)) + (-9 * cubicAValue * cubicBValue * cubicCValue) + (27 * …
Run Code Online (Sandbox Code Playgroud)

c# math polynomial-math c#-4.0

0
推荐指数
1
解决办法
1469
查看次数

C++ Cubic Spline轨迹

我正在编写一个C++程序来为一组点生成三次样条轨迹.这些点不需要沿x轴排序.例如,它可能是一个圆圈等.

我在网上找到了一些库,例如,ALGLIB库或这里的类https://www.marcusbannerman.co.uk/index.php/home/42-articles/96-cubic-spline-class.html,但所有这些库都对数据点进行排序.我不需要这个,因为我想要生成的东西就像一个圆圈.反正有没有实现这个目标?

c++ math spline polynomial-math

0
推荐指数
1
解决办法
2322
查看次数

在Haskell中将多项式转换为标准形式

在Haskell中,我使用的是自定义数据类型Poly a = X | Coef a | Sum (Poly a) (Poly a) | Prod (Poly a) (Poly a) deriving (Show).

因此,多项式(3 + x)^ 2将表示为(Prod (Sum (Coef 3) X) (Sum (Coef 3) X)).

我很难将以这种方式输入的多项式转换为其标准形式的系数列表,我相信它将[9, 6, 1]为(3 + x)^ 2 = 9 + 6x + x ^ 2.

我相信一个可能的解决方案是在我的多项式数据类型上实现一些数学函数,这样我就可以简化输入,但是我没有成功.还有另外一种方法吗?

有人能指出我正确的方向吗?

computer-science haskell functional-programming polynomial-math simplification

0
推荐指数
1
解决办法
343
查看次数

如何在没有指数运算符的情况下使用C编程转换多项式?

我正在查看我的C教科书,里面有一个页面,提示告诉我将多项式转换为C代码.我们还没有讨论指数运算符,并且特别指示此时不使用它们并找到基本运算符的另一种方法.多项式如下:5x^(2)+3x-2.

我该怎么做呢?

c operators polynomial-math

0
推荐指数
1
解决办法
88
查看次数

c ++中的模板错误

#include<iostream>
using namespace std;
template<class T>

struct term

{
          T coef;

          int exp;


};
template<class T>
class Polynomial
{
 public:
   class term<T> *termarray;
   int capacity;
   int terms;

   Polynomial(int size);
   ~Polynomial()
   {
       delete[] termarray;
   }

   Polynomial& Add(Polynomial b);
   Polynomial& Mul(Polynomial b);
   void NewTerm(const float theCoef,const int theExp);
   void show();
   };

template<class T>
   Polynomial::Polynomial(int size)// Invalid use of template-name'Polynomial'without argument list
  {
   terms=0;
   this->termarray=new T [size];
   capacity=size;
   for(int i=0;i<size;i++)
{
    cout<<"enter the coefficient of the "<<i<<"th exponent coeffecient"<<endl;
    cin>>this->termarray[i].coef;
    terms++;
}

} …
Run Code Online (Sandbox Code Playgroud)

c++ templates polynomial-math

-1
推荐指数
1
解决办法
740
查看次数