001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.commons.math.special;
019
020 import org.apache.commons.math.MathException;
021
022 import junit.framework.TestCase;
023
024 /**
025 * @version $Revision: 670469 $ $Date: 2008-06-23 04:01:38 -0400 (Mon, 23 Jun 2008) $
026 */
027 public class ErfTest extends TestCase {
028
029 public void testErf0() throws MathException {
030 double actual = Erf.erf(0.0);
031 double expected = 0.0;
032 assertEquals(expected, actual, 1.0e-5);
033 }
034
035 public void testErf1960() throws MathException {
036 double x = 1.960 / Math.sqrt(2.0);
037 double actual = Erf.erf(x);
038 double expected = 0.95;
039 assertEquals(expected, actual, 1.0e-5);
040
041 actual = Erf.erf(-x);
042 expected = -expected;
043 assertEquals(expected, actual, 1.0e-5);
044 }
045
046 public void testErf2576() throws MathException {
047 double x = 2.576 / Math.sqrt(2.0);
048 double actual = Erf.erf(x);
049 double expected = 0.99;
050 assertEquals(expected, actual, 1.0e-5);
051
052 actual = Erf.erf(-x);
053 expected = -expected;
054 assertEquals(expected, actual, 1.0e-5);
055 }
056
057 public void testErf2807() throws MathException {
058 double x = 2.807 / Math.sqrt(2.0);
059 double actual = Erf.erf(x);
060 double expected = 0.995;
061 assertEquals(expected, actual, 1.0e-5);
062
063 actual = Erf.erf(-x);
064 expected = -expected;
065 assertEquals(expected, actual, 1.0e-5);
066 }
067
068 public void testErf3291() throws MathException {
069 double x = 3.291 / Math.sqrt(2.0);
070 double actual = Erf.erf(x);
071 double expected = 0.999;
072 assertEquals(expected, actual, 1.0e-5);
073
074 actual = Erf.erf(-x);
075 expected = -expected;
076 assertEquals(expected, actual, 1.0e-5);
077 }
078 }