【Java开源代码栏目提醒】:网学会员Java开源代码为您提供d5r5.java参考,解决您在d5r5.java学习中工作中的难题,参考学习。
import java.text.*;
public class d5r5
{
public static void main (String[] args)
{
//program d5r5
//driver for routine chebev
int nval = 40;
double x, pio2 = 1.5707963;
double a, b;
double c[] = new double[41];
a = -pio2;
b = pio2;
d5r5F g = new d5r5F();
DecimalFormat form = new DecimalFormat("0.000000");
g.chebft(a, b, c, nval);
//test chebyshev evaluation routine
System.out.println();
System.out.println("How many terms in chebyshev evaluation?");
//input mval , between 6 and 40, mval=0 to end
int mval = 20;
System.out.println(mval);
if ((mval <= 0) || (mval > nval))
{
return;
}
System.out.println(" x Actual Chebyshev fit");
for (int i = -8; i <= 8; i++)
{
x = i * pio2 / 10.0;
System.out.print(" "+form.format(x) + " ");
System.out.print(form.format(g.func(x)) + " ");
System.out.println(form.format(g.chebev(a, b, c, mval, x)) + " ");
}
}
}