求解一个积分公式 在JAVA中如何实现?
不知道如何在这里贴图,积分的公式是保存在WORD图片中的。有什么方法能够贴上来?

解决方案 »

  1.   

    靠,要是简单的还行,有些难算的可就不好办了不过你可以求近似值,那倒是很简单的,只要累积N个f(Xn)*d就行。
      

  2.   

    数学积分都要用java实现,关注……
      

  3.   

    用matlab吧,顺便问matlab能和vc公用,和java行吗?
      

  4.   

    to Hodex用什么语言好象都差不多,关键是思路有了公式 还要什么思路?
      

  5.   

    梯形求积法:
    public class d3r1F 
    {
    double trapzd_s;
    void trapzd(double a, double b, double s, int n)
    {
    double del,x,sum;
    int j, it, tnm;
            if (n == 1)
    {
                s = 0.5 * (b - a) * (func(a) + func(b));
                it = 1;
    }
            else
    {
                it = (int)Math.pow(2 , n - 2);
                tnm = it;
                del = (b - a) / tnm;
                x = a + 0.5 * del;
                sum = 0.0;
                for (j = 1; j <= it; j++)
    {
                    sum = sum + func(x);
                    x = x + del;
                }
                s = 0.5 * (s + (b - a) * sum / tnm);
            }
    trapzd_s = s;
    } double func(double x)
    {
            return (x * x) * (x * x - 2.0) * Math.sin(x);
    } double fint(double x)
    {
    double aaa = 4.0 * x * (x * x - 7.0) * Math.sin(x);
    return aaa - (x * x * x * x - 14.0 * x * x + 28.0) * Math.cos(x);
    }
    }
    //
    /****************
    *
    *
    */
    //例子
    import java.text.*;
    public class d3r1
    {
    public static void main (String[] args)
    {
    //program d3r1
    //driver for routine trapzd
    int i;
    int nmax = 14;
    double pio2 = 1.5707963;
    double s,b,a = 0.0;
    s = 0;
    d3r1F g = new d3r1F();
    DecimalFormat form = new DecimalFormat("0.000000");
    b = pio2;
    System.out.println();
    System.out.println("integral of func with 2^(n-1) points");
    System.out.print("actual value of integral is: ");
    System.out.println(form.format((g.fint(b) - g.fint(a))));
    System.out.println();
    System.out.println("n     approx.integral");
    for (i = 1; i <= nmax; i++)
    {
                g.trapzd(a, b, s, i);
    s = g.trapzd_s;
                System.out.print(i + "        ");
                System.out.println(form.format(s));
    }
    }
    }
      

  6.   

    to tiger999(不吃肉的老虎)照你这么说,有了公式就有了思路,那还用你编什么?问题是哪种算法更接近于积分结果
      

  7.   

    >>从图片中读积分公式然后求解?难呵呵,好恐怖!!!
      

  8.   

    数学积分都要用java实现,关注……
      

  9.   

    好像没什么说的啊,求近似值啊!标准的积分啊!$a                                                                                        $b f(x)dx
      

  10.   

    public class d3r1F 
    {
    double trapzd_s;
    void trapzd(double a, double b, double s, int n)
    {
    double del,x,sum;
    int j, it, tnm;
            if (n == 1)
    {
                s = 0.5 * (b - a) * (func(a) + func(b));
                it = 1;
    }
            else
    {
                it = (int)Math.pow(2 , n - 2);
                tnm = it;
                del = (b - a) / tnm;
                x = a + 0.5 * del;
                sum = 0.0;
                for (j = 1; j <= it; j++)
    {
                    sum = sum + func(x);
                    x = x + del;
                }
                s = 0.5 * (s + (b - a) * sum / tnm);
            }
    trapzd_s = s;
    } double func(double x)
    {
            return (x * x) * (x * x - 2.0) * Math.sin(x);
    } double fint(double x)
    {
    double aaa = 4.0 * x * (x * x - 7.0) * Math.sin(x);
    return aaa - (x * x * x * x - 14.0 * x * x + 28.0) * Math.cos(x);
    }
    }
    //
    /****************
    *
    *
    */
    //例子
    import java.text.*;
    public class d3r1
    {
    public static void main (String[] args)
    {
    //program d3r1
    //driver for routine trapzd
    int i;
    int nmax = 14;
    double pio2 = 1.5707963;
    double s,b,a = 0.0;
    s = 0;
    d3r1F g = new d3r1F();
    DecimalFormat form = new DecimalFormat("0.000000");
    b = pio2;
    System.out.println();
    System.out.println("integral of func with 2^(n-1) points");
    System.out.print("actual value of integral is: ");
    System.out.println(form.format((g.fint(b) - g.fint(a))));
    System.out.println();
    System.out.println("n     approx.integral");
    for (i = 1; i <= nmax; i++)
    {
                g.trapzd(a, b, s, i);
    s = g.trapzd_s;
                System.out.print(i + "        ");
                System.out.println(form.format(s));
    }
    }
    }
    不能运行呀,请指点!谢谢
      

  11.   


    UP,楼上的,数学系计算科学的吧to 楼主:看你要怎么算了,要算到什么精度??具体算法请参阅:计算方法