Java_304 tests


davekw7x
11-06-2012, 12:01 PM
// Xcaldat.java
//
// Test for Calendar static functions to convert
// month/day/year to Julian calendar day and
// back. The functions are static functions
// of the Calendar class.
//
// davekw7x
//
import static com.nr.util.Calendar.caldat;
import static com.nr.util.Calendar.julday;

//
// To be able to use intW, import the netlib util stuff.
// This is in lib/f2util.jar of the Java_304 distribution.
//
import org.netlib.util.intW;

public class Xcaldat {

// These particular dates were in the original test
// programs from Numerical recipes version 2 C and C++
// example files.
public static void main(String [] args) {
int nmonth[] = { 12, 1, 10, 10, 1, 4, 4, 5,
7, 5, 7, 4, 5, 7, 6, 5,
11};
int nday[] = { 31, 1, 4, 15, 17, 14, 18, 7,
20, 23, 22, 3, 6, 26, 5, 23,
4};
int nyear[] = { -1, 1,1582,1582,1706,1865,1906,1915,
1923,1934,1934,1936,1937,1956,1976,1968,
2012};

int siz = nmonth.length;

// Go through the arrays of dates. Use mm/dd/yyyy to obtain
// Julian date from julday and then use the julian day
// with caldat to retrive original mm/dd/yyyy.
// Print out any discrepancies.
//
for (int i = 0; i < siz; i++) {
int im = nmonth[i];
int id = nday[i];
int iy = nyear[i];
int j = julday(im, id, iy); // Arguments are month, day, year

// Mutable wrappers for ints to emulate C/C++ pointer arguments
// or C++ pass by reference
intW idd = new intW(0);
intW imm = new intW(0);
intW iyy = new intW(0);

caldat(j, imm, idd, iyy);

// I'll just print the numerical value of weekday with
// 1 ==> Sunday, 2 ==> Monday, etc.
int weekday = 1 + (1 + j)%7;

System.out.printf("%5d/%2d/%2d: %d, weekday = %d\n",
iy, im, id, j, weekday);
if (iyy.val != iy) {
System.err.printf("***Year : Original = %d, round-trip = %d\n",
iyy.val, iy);
}
if (imm.val != im) {
System.err.printf("***Month: Original = %d, round-trip = %d\n",
imm.val, im);
}
if (idd.val != id) {
System.err.printf("***Day : Original = %d, round-trip = %d\n",
idd.val, id);
}
}
}
}


Output:

-1/12/31: 1721423, weekday = 6
1/ 1/ 1: 1721424, weekday = 7
1582/10/ 4: 2299160, weekday = 5
1582/10/15: 2299161, weekday = 6
1706/ 1/17: 2344180, weekday = 1
1865/ 4/14: 2402341, weekday = 6
1906/ 4/18: 2417319, weekday = 4
1915/ 5/ 7: 2420625, weekday = 6
1923/ 7/20: 2423621, weekday = 6
1934/ 5/23: 2427581, weekday = 4
1934/ 7/22: 2427641, weekday = 1
1936/ 4/ 3: 2428262, weekday = 6
1937/ 5/ 6: 2428660, weekday = 5
1956/ 7/26: 2435681, weekday = 5
1976/ 6/ 5: 2442935, weekday = 7
1968/ 5/23: 2440000, weekday = 5
2012/11/ 4: 2456236, weekday = 1


The one that I am absolutely sure about is the last one: Nov 4, 2012 was Sunday. (Others that I checked seemed to be correct also.)

Now, here's how I organized my project.

First of all, I use command-line compilation for simple projects like this. If you use NetBeans or Eclipse or some other IDE, you can organize things any way that you want. I'm not promising to be able to help (or even to try to help).

Here's what I did:
From the unzipped Java_304 installation directory, I made a directory that I called Xcaldat. That's where I put the above file, named Xcaldat.java

I made a couple of shell scripts to compile and run the program. Since programs like this only have one Java file, the scripts are simple. I didn't see any reason to create a build.xml to use with ant, (but I did, just for kicks). Windows users can make bat files to do the equivalent.

Here's compile.sh:

#! /bin/sh
# Compile a Java file into a class in the current directory
echo "javac -cp ../build/lib/nr3.jar:../lib/f2jutil.jar $1" && \
javac -cp ../build/lib/nr3.jar:../lib/f2jutil.jar $1


I copy this into all new project directories that I create.

I made it executable so that I compile Xcaldat.java by the following command line;

./compile Xcaldat.java


Similarly I run the program (after successful compilation) by invoking a "run.sh" script:

# !/bin/sh
# Execute java on a previously compiled class
#
echo "java -cp .:../build/lib/nr3.jar:../lib/f2jutil.jar $1" && \
java -cp .:../build/lib/nr3.jar:../lib/f2jutil.jar $1


Then I run the program with

./run.sh Xcaldat


Actual commands to compile and run were

javac -cp ../build/lib/nr3.jar:../lib/f2jutil.jar Xcaldat.java
java -cp .:../build/lib/nr3.jar:../lib/f2jutil.jar Xcaldat



Regards,

Dave

davekw7x
11-06-2012, 12:09 PM
//
// Xgaussj.java
//
// Solve 3x3 system of equations with Java_304 Gauss Jordan function
//
// davekw7x
//
import com.nr.NRUtil;

// gaussj is a function of the GaussJordan Class
import com.nr.la.GaussJordan;


public class Xgaussj {

public static void main(String [] args) {
int siz = 3;
double [][] aa = {
{1.0, 2.0, 2.0},
{4.0, -4.0, -3.0},
{2.0, 4.0, 5.0}
};

// Since gaussj destroys the original, make a copy
double[][] aac = new double[siz][siz];
NRUtil.copyAssign(aac, aa);

// RHS is has one column (It's a vector)
double [] b = {2.0, 2.0, 2.0};
System.out.println("LHS:\n" + NRUtil.toString(aac));
System.out.println("RHS : " + NRUtil.toString(b));

// gaussj requires a 2-D matrix on the RHS.
// If the RHS is a vector, you need an Nx1 matrix.
// here's a way to do it
double [][] bb = NRUtil.buildMatrix(3, 1, b);

// Or, you could just do the following (but you would have to
// create something else to save the original RHS
// for checking anyhow).
//double [][] bb = {{2.0},{2.0},{2.0}};
GaussJordan.gaussj(aa, bb);

double [] ans = new double[siz];
for (int i = 0; i < siz; i++) {
ans[i] = bb[i][0];
}

System.out.println("\nAnswer : " + NRUtil.toString(ans));
double [] check = prodMatVec(aac, ans);
System.out.println("Check : " + NRUtil.toString(check));
for (int i = 0; i < check.length; i++) {
check[i] -= b[i];
}
System.out.println();
System.out.println("Residuals: " + NRUtil.toString(check));

}
// A simple function that multiples a matrix times a vector
// and returns the vector.
// TODO: Put in consistency checks to make sure number
// of columns of m is equal to the size of x
//
static double [] prodMatVec(double [][] m, double [] x) {
int siz = m.length;
double [] prod = new double[siz];
for (int i = 0; i < siz; i++) {
double sum = 0.0;
for (int j = 0; j < siz; j++) {
sum += m[i][j] * x[j];
}
prod[i] = sum;
}
return prod;
}
}


Output:

LHS:
1.00000 2.00000 2.00000
4.00000 -4.00000 -3.00000
2.00000 4.00000 5.00000

RHS : 2.00000 2.00000 2.00000

Answer : 1.33333 2.33333 -2.00000
Check : 2.00000 2.00000 2.00000

Residuals: 0.00000 8.88178e-16 0.00000


The source was placed in directory Xgaussj below the Java_304 main directory. Compilation and execution were done with the same scripts I showed in the previous post.

Actual compile and execution commands were

javac -cp ../build/lib/nr3.jar:../lib/f2jutil.jar Xgaussj.java
java -cp .:../build/lib/nr3.jar:../lib/f2jutil.jar Xgaussj



Regards,

Dave

davekw7x
11-06-2012, 12:29 PM
//
// Xzroots1.java
//
// Find complex zeros of complex polynomial using zroots
//
// davekw7x
//

// Need the Complex class
import com.nr.Complex;

// zroots is a static function of the Roots class.
import static com.nr.root.Roots.zroots;

public class Xzroots1 {
public static void main(String [] args) {
//
// This is for x^4 -(1+2i) + 2i
// Note that there are five coefficients
// for a fourth degree polynomial.
//
Complex [] c = new Complex [] {
new Complex( 0.0, 2.0), // Constant term
new Complex( 0.0, 0.0), // Coefficient of x^1
new Complex(-1.0, -2.0), // Coefficient of x^2
new Complex( 0.0, 0.0), // Coefficient of x^3
new Complex( 1.0, 0.0) // Coefficient of x^4
};
System.out.println("Find Roots of x^4 -(1+2i)x^2 + 2i:\n");
for (int i = 0; i < c.length; i++) {
System.out.printf("Coeff %d = %s\n", i, c[i]);
}
System.out.println();

// Array to hold the complex roots
Complex [] roots = new Complex[c.length-1];

// Solve with the static function zroots
boolean polish = true;
zroots(c, roots, polish);

for (int i = 0; i < roots.length; i++) {
System.out.printf("Root %d = %s\n", i, roots[i]);
}

System.out.println();
for (int i = 0; i < roots.length; i++) {
Complex check = polyVal(c, roots[i]);
System.out.printf("Check %d = %s\n", i, check);
}
}

//
// Evaluate complex polynomial with complex argument
//
public static Complex polyVal(Complex [] coeffs, Complex val) {
Complex result = new Complex(); // Initialized as (0,0)
for (int i = coeffs.length-1; i >= 0; i--) {
result = result.mul(val).add(coeffs[i]);
}
return result;
}
}

Output:
Find Roots of x^4 -(1+2i)x^2 + 2i:

Coeff 0 = (0.0 + 2.0i)
Coeff 1 = (0.0 + 0.0i)
Coeff 2 = (-1.0 - 2.0i)
Coeff 3 = (0.0 + 0.0i)
Coeff 4 = (1.0 + 0.0i)

Root 0 = (-1.0 - 1.0i)
Root 1 = (-1.0 + 0.0i)
Root 2 = (1.0 + 1.0i)
Root 3 = (1.0 + 0.0i)

Check 0 = (0.0 + 0.0i)
Check 1 = (0.0 + 0.0i)
Check 2 = (0.0 + 0.0i)
Check 3 = (0.0 + 0.0i)


Procedure same as previous examples: Create a file named Xzroots1.java in new directory Xzroots below the Java_304 main directory.

Compile and run with

javac -cp ../build/lib/nr3.jar:../lib/f2jutil.jar Xzroots1.java
java -cp .:../build/lib/nr3.jar:../lib/f2jutil.jar Xzroots1


Now, to find zeros of another polynomial, create another file, named Xzroots.java, in the same directory.

Copy Xzroots1.java to Xzroots.java and make changes near the beginning:

//
// Xzroots.java
//
// Find complex roots of real polynomial using zroots
//
// davekw7x
//

// Need the Complex class
import com.nr.Complex;

// zroots is a static function of the Roots class.
import static com.nr.root.Roots.zroots;

public class Xzroots {
public static void main(String [] args) {
//
// Five coefficients for a fourth-degree polynomial
//
// Coefficients are actually real, but need
// complex array to feed zroots.
//
// This is for 0.00193 + 0.098243 x + 25.024523 x^2 + 6.238928 x^3 + x ^4
//
// So, a fourth degree polynomial requires five coefficients
Complex [] c = new Complex [] {
new Complex( 0.000193, 0.000000),
new Complex( 0.098243, 0.000000),
new Complex(25.024523, 0.000000),
new Complex( 6.238928, 0.000000),
new Complex( 1.000000, 0.000000)
};
for (int i = 0; i < c.length; i++) {
System.out.printf("Coeff %d = %s\n", i, c[i]);
}
System.out.println();
.
. // Rest of file same as Xzroots1.java
.


Compile and run with

javac -cp ../build/lib/nr3.jar:../lib/f2jutil.jar Xzroots.java
java -cp .:../build/lib/nr3.jar:../lib/f2jutil.jar Xzroots


Output:

Coeff 0 = (1.93E-4 + 0.0i)
Coeff 1 = (0.098243 + 0.0i)
Coeff 2 = (25.024523 + 0.0i)
Coeff 3 = (6.238928 + 0.0i)
Coeff 4 = (1.0 + 0.0i)

Root 0 = (-3.1175001046865876 + 3.9091199267746135i)
Root 1 = (-3.1175001046865867 - 3.9091199267746135i)
Root 2 = (-0.0019638953134130713 - 0.0019654789040163515i)
Root 3 = (-0.0019638953134130713 + 0.0019654789040163515i)

Check 0 = (-1.4051943202780803E-13 + 3.8918602498702604E-14i)
Check 1 = (3.258051922867822E-14 + 6.294064661821475E-16i)
Check 2 = (0.0 + 0.0i)
Check 3 = (0.0 + 0.0i)



Regards,

Dave

davekw7x
11-06-2012, 03:00 PM
Uses the Java_304 Cholesky decomposition to solve system of equations, but uses standard Java stuff for printing uniformly formatted matrix and vector output instead of the quick-and-easy-but-butt-ugly NRUtil functions


//
// Xcholesky.java
//
// Solve system of equatons with Cholesky decomposition
//
// davekw7x
//
import com.nr.la.Cholesky;

public class Xcholesky {

public static void main(String [] args) {

//
// The coefficient matrix
//
double [][] a = {
{100.00, 15.00, 0.01},
{ 15.00, 2.30, 0.01},
{ 0.01, 0.01, 1.00}
};

//
// The right-hand side vector
//
double [] b = {
0.40,
0.02,
99.00
};
System.out.println("Matrix a:");
printMat(a);

System.out.println("Right-hand side b:");
printVec(b);

//
// Vector to hold the solution
//
double [] x = new double[b.length];

//
// Instantiate Cholesky object
// Decomposition is done in constructor
//
Cholesky ch = new Cholesky(a);

//
// Get solution for this right hand side
//
ch.solve(b, x);
System.out.println("Solution x:");
printVec(x);

//
// Multiply matrix times solution vector
// p is product vector
//
double [] p = new double[x.length];
for (int i = 0; i < a.length; i++) {
double sum = 0.0;
for (int j = 0; j < a.length; j++) {
sum += a[i][j]*x[j];
}
p[i] = sum;
}

//
// Show result and residual
//
System.out.println(" a*x b residual");
for (int i = 0; i < p.length; i++) {
System.out.printf(" %13.5e %13.5e %13.5e\n", p[i], b[i], p[i]-b[i]);
}

} // End main

//
// Print matrix in scientific format with six significant digits
//
static void printMat(double [][] m) {
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m[i].length; j++) {
System.out.printf(" %13.5e", m[i][j]);
}
System.out.println();
}
System.out.println();
} // End printMat

//
// Print vector in scientific format with six significant digits
//
static void printVec(double [] v) {
for (int i = 0; i < v.length; i++) {
System.out.printf(" %13.5e\n", v[i]);
}
System.out.println();
} // End printVec

} // End class definition


From Xcholesky directory under Java_304 main directory, compile and run with:

javac -cp ../build/lib/nr3.jar:../lib/f2jutil.jar Xcholesky.java
java -cp .:../build/lib/nr3.jar:../lib/f2jutil.jar Xcholesky


Output:
Matrix a:
1.00000e+02 1.50000e+01 1.00000e-02
1.50000e+01 2.30000e+00 1.00000e-02
1.00000e-02 1.00000e-02 1.00000e+00

Right-hand side b:
4.00000e-01
2.00000e-02
9.90000e+01

Solution x:
2.64241e+00
-1.76555e+01
9.91501e+01

a*x b residual
4.00000e-01 4.00000e-01 -2.53131e-14
2.00000e-02 2.00000e-02 5.72459e-16
9.90000e+01 9.90000e+01 1.42109e-14



Regards,

Dave

davekw7x
11-07-2012, 12:51 PM
As a person with a certain amount of experience with C and C++, when I started looking at Java a few months ago I wondered how the heck I could live without pointers. Specifically: What would I do when I needed a pointer to a function? How can I implement application functionality that requires callback functions if there is no such thing as a pointer to function?

The answer: Java interfaces. The Java_304 distribution supplies some that we can use for things like quadrature with Simpson's rule. It requires that we feed a very specific kind of function to qsimp.


//
// Xqsimp.java
//
//
// The UniVarRealValueFun interface plays the role
// of a C++ functor to provide the Java equivalent of
// "pointer to function"
//
// This example approximates the integral of 1/(x^2 - alpha^2)
// over a given interval for a given alpha. Alpha must not be in
// the interval (or gablooie).
//
// davekw7x
//

import com.nr.*;
import com.nr.fi.Trapzd;

public class Xqsimp implements UniVarRealValueFun {
public static void main(String [] args) {

// Function parameter
//
double alp = 2.0; // Alpha for the function 1/(x^2-alpha^2)

// Limits of integration
//
double a = 0.0;
double b = 1.0;

System.out.println("Use of composite Simpson's rule to find the approximate value of the integral");
System.out.printf("of 1.0/(x^2 - alpha^2) from %.1f to %.1f for alpha = %.1f\n\n", a, b, alp);

// Constructor for this object sets value of alpha
//
Xqsimp f = new Xqsimp(alp);

// Getting the approximation is as simple as this:
//
double value = Trapzd.qsimp(f, a, b);

// I wouldn't choose a test function for which I didn't know
// the analytic solution, would I? So...
//
double exact = f.antiDerivative(b) - f.antiDerivative(a);

System.out.printf("Value from qsimp = %.15f\n", value);
System.out.printf("Actual value = %.15f\n", exact);
System.out.printf("Error = %.6e\n", value - exact);

} // End main


// Variable that appears in function to be integrated
//
double alpha;

// Constructor sets value of object field alpha
//
Xqsimp(double a) {
alpha = a;
}

//
// This is the function to be integrated with qsimp:
// 1/(x^2 - alpha^2)
//
// It MUST have the name "funk" and must have
// a single parameter that is a double and it
// must return a double.
//
public double funk(double x) {
return 1.0/(x*x - alpha*alpha);
}

// Analytic anti-derivative of test function for
// comparison with approximate value from qsimp
//
double antiDerivative(double x)
{
double retval;
if (alpha == x) {
retval = (-1.0/x);
}
else {
retval = Math.log(Math.abs((x-alpha)/(x+alpha))) / (2.0*alpha);
}
return retval;
}

} // End class definition


Output:
Use of composite Simpson's rule to find the approximate value of the integral
of 1.0/(x^2 - alpha^2) from 0.0 to 1.0 for alpha = 2.0

Value from qsimp = -0.274653072167147
Actual value = -0.274653072167027
Error = -1.197376e-13


Regards,

Dave

Footnote:
This is the last of my tests for a while. I just wanted to share my preliminary experiences with the Java version of NR3. I have no real interest in doing any of this stuff in Java just now, but I am always interested in seeing what others are doing. (I know you are out there. I can hear you breathing.)

kutta
06-15-2014, 06:12 AM
Uses the Java_304 Cholesky decomposition to solve system of equations, but uses standard Java stuff for printing uniformly formatted matrix and vector output instead of the quick-and-easy-but-butt-ugly NRUtil functions


//
// Xcholesky.java
//
// Solve system of equatons with Cholesky decomposition
//
// davekw7x
//
import com.nr.la.Cholesky;

public class Xcholesky {

public static void main(String [] args) {

//
// The coefficient matrix
//
double [][] a = {
{100.00, 15.00, 0.01},
{ 15.00, 2.30, 0.01},
{ 0.01, 0.01, 1.00}
};

//
// The right-hand side vector
//
double [] b = {
0.40,
0.02,
99.00
};
System.out.println("Matrix a:");
printMat(a);

System.out.println("Right-hand side b:");
printVec(b);

//
// Vector to hold the solution
//
double [] x = new double[b.length];

//
// Instantiate Cholesky object
// Decomposition is done in constructor
//
Cholesky ch = new Cholesky(a);

//
// Get solution for this right hand side
//
ch.solve(b, x);
System.out.println("Solution x:");
printVec(x);

//
// Multiply matrix times solution vector
// p is product vector
//
double [] p = new double[x.length];
for (int i = 0; i < a.length; i++) {
double sum = 0.0;
for (int j = 0; j < a.length; j++) {
sum += a[i][j]*x[j];
}
p[i] = sum;
}

//
// Show result and residual
//
System.out.println(" a*x b residual");
for (int i = 0; i < p.length; i++) {
System.out.printf(" %13.5e %13.5e %13.5e\n", p[i], b[i], p[i]-b[i]);
}

} // End main

//
// Print matrix in scientific format with six significant digits
//
static void printMat(double [][] m) {
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m[i].length; j++) {
System.out.printf(" %13.5e", m[i][j]);
}
System.out.println();
}
System.out.println();
} // End printMat

//
// Print vector in scientific format with six significant digits
//
static void printVec(double [] v) {
for (int i = 0; i < v.length; i++) {
System.out.printf(" %13.5e\n", v[i]);
}
System.out.println();
} // End printVec

} // End class definition


From Xcholesky directory under Java_304 main directory, compile and run with:

javac -cp ../build/lib/nr3.jar:../lib/f2jutil.jar Xcholesky.java
java -cp .:../build/lib/nr3.jar:../lib/f2jutil.jar Xcholesky


Output:
Matrix a:
1.00000e+02 1.50000e+01 1.00000e-02
1.50000e+01 2.30000e+00 1.00000e-02
1.00000e-02 1.00000e-02 1.00000e+00

Right-hand side b:
4.00000e-01
2.00000e-02
9.90000e+01

Solution x:
2.64241e+00
-1.76555e+01
9.91501e+01

a*x b residual
4.00000e-01 4.00000e-01 -2.53131e-14
2.00000e-02 2.00000e-02 5.72459e-16
9.90000e+01 9.90000e+01 1.42109e-14



Regards,

Dave

Hello
The same xcholesky was tried by me by way of one method elimination namely
solve(x,b);in lieu of non availability of the this method at present,the results obtained on execution of the above codes (without use of import com.nr.la.Cholesky;) are herby appended here for you to continue further with the same motivation as you had initially after all success folllows only by keep trying methods Welldone
Thanks
As
C.R.Muthukumar(kutta)





public class xcholesky extends MatrixDemo{

public static void main(String [] args) {


// xcholesky ch;

// ch=new xcholesky();

//
// The coefficient matrix
//
double [][] a = {
{100.00, 15.00, 0.01},
{ 15.00, 2.30, 0.01},
{ 0.01, 0.01, 1.00}
};

//
// The right-hand side vector
//
double [] b = {
0.40,
0.02,
99.00
};
System.out.println("Matrix a:");
printMat(a);

System.out.println("Right-hand side b:");
printVec(b);

//
// Vector to hold the solution
//
double [] x = new double[b.length];

//
// Instantiate Cholesky object
// Decomposition is done in constructor
//
xcholesky ch = new xcholesky();

//
// Get solution for this right hand side
//
// ch.solve(b, x);
System.out.println("Solution x:"+"");
printVec(x);

//
// Multiply matrix times solution vector
// p is product vector
//
double [] p = new double[x.length];
for (int i = 0; i < a.length; i++) {
double sum = 0.0;
for (int j = 0; j < a.length; j++) {
sum += a[i][j]*x[j];
}
p[i] = sum;
}

//
// Show result and residual
//
System.out.println(" a*x b residual");
for (int i = 0; i < p.length; i++) {
System.out.printf(" %13.5e %13.5e %13.5e\n", p[i], b[i], p[i]-b[i]);
}

} // End main

//
// Print matrix in scientific format with six significant digits
//
static void printMat(double [][] m) {
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m[i].length; j++) {
System.out.printf(" %13.5e", m[i][j]);
}
System.out.println();
}
System.out.println();
} // End printMat

//
// Print vector in scientific format with six significant digits
//
static void printVec(double [] v) {
for (int i = 0; i < v.length; i++) {
System.out.printf(" %13.5e\n", v[i]);
}
System.out.println();
} // End printVec

} // End class definition

class MatrixDemo
{
public static void printMat( int [ ][ ] m )
{
for( int i = 0; i < m.length; i++ )
{
if( m[ i ] == null )
System.out.println( "(null)" );
else
{
for( int j = 0; j < m[i].length; j++ )
System.out.print( m[ i ][ j ] + " " );
System.out.println( );
}
}
}

}

/**
Matrix a:
1.00000e+02 1.50000e+01 1.00000e-02
1.50000e+01 2.30000e+00 1.00000e-02
1.00000e-02 1.00000e-02 1.00000e+00

Right-hand side b:
4.00000e-01
2.00000e-02
9.90000e+01

Solution x:
0.00000e+00
0.00000e+00
0.00000e+00

a*x b residual
0.00000e+00 4.00000e-01 -4.00000e-01
0.00000e+00 2.00000e-02 -2.00000e-02
0.00000e+00 9.90000e+01 -9.90000e+01
. . .
*/