import javax.swing.*;
import java.awt.*;

public class numeric1
{   public static void main(String arg[])
    {numeric1 nm1=new numeric1();}
    public numeric1()
    {
    Object[] o={"Bisection root finding",	
                "False position root finding",
                "Stephensen root finding",
                "Brent root finding",
                "Ridder root finding",	
                "Newton root finding",
                "Secant root finding",
                "Inverse interpolation root finding",
                "Muller root finding",	
                "Newton-bisection root finding",
                "Golden search optimisation",		
                "Quadratic polynomial optimisation",
                "Cubic polynomial optimisation",	
                "Newton optimisation",
                "Brent optimisation",
                "Gauss-Legendre Integration",
                "Adaptive Gauss-Lobatto Integration",
                "Adaptive Simpson Integration",
                "Adaptive Gauss-Kronroad Integration",
                "First order derivative",
                "nth order derivative",
                "plot the function"};
    ImageIcon picture=new ImageIcon("fall.jpg");              
    String name=(String)JOptionPane.showInputDialog(null,"Please select a name : ",
    "Numerical analysis by java examples simple function methods",JOptionPane.QUESTION_MESSAGE,picture,o,"Bisection root finding");
    if(name=="Bisection root finding")
    {
	double a[]=Text.readDoubleV("x_low,x_high = ");
	double x=ez.bisection(a[0],a[1]);
	ez.print(name+" root x="+x,name+" method");
	}
	else if(name=="False position root finding")
    {
	double a[]=Text.readDoubleV("x_low,x_high = ");
	double x=ez.false_position(a[0],a[1]);
	ez.print(name+" root x="+x,name+" method");
	}
    else if(name=="Stephensen root finding")
    {
	double a[]=Text.readDoubleV("x   = ");
	double x=ez.stefensen(a[0]);
	ez.print(name+" root x="+x,name+" method");
	}
	else if(name=="Brent root finding")
    {
	double a[]=Text.readDoubleV("x_low,x_high = ");
	double x=ez.brent(a[0],a[1]);
	ez.print(name+" root x="+x,name+" method");
	}
	else if(name=="Ridder root finding")
    {
	double a[]=Text.readDoubleV("x_low,x_high = ");
	double x=ez.ridder(a[0],a[1]);
	ez.print(name+" root x="+x,name+" method");
	}
	else if(name=="Newton root finding")
    {
	double a[]=Text.readDoubleV("x0 = ");
	double x=ez.newton(a[0]);
	ez.print(name+" root x="+x,name+" method");
	}
	else if(name=="Secant root finding")
    {
	double a[]=Text.readDoubleV("x0 = ");
	double x=ez.secant(a[0]);
	ez.print(name+" root x="+x,name+" method");
	}
	else if(name=="Inverse interpolation root finding")
    {
	double a[]=Text.readDoubleV("x0,x1,x2 = ");
	double x=ez.inverseinterpolation(a[0],a[1],a[2]);
	ez.print(name+" root x="+x,name+" method");
	}
	else if(name=="Muller root finding")
    {
	double a[]=Text.readDoubleV("x0,x1,x2 = ");
	double x=ez.muller(a[0],a[1],a[2]);
	ez.print(name+" root x="+x,name+" method");
	}
	else if(name=="Newton-bisection root finding")
    {
	double a[]=Text.readDoubleV("x_low,x_high = ");
	double x=ez.newton_bisection(a[0],a[1]);
	ez.print(name+" root x="+x,name+" method");
	}
	else if(name=="Golden search optimisation")
    {
	double a[]=Text.readDoubleV("x_low,x_high = ");
	double x=ez.golden_search(a[0],a[1]);
	ez.print(name+" optimum point x="+x,name+" method");
	}
	else if(name=="Quadratic polynomial optimisation")
    {
	double a[]=Text.readDoubleV("x_low,x_high = ");
	double x=ez.quadratic_polynomial_search(a[0],a[1]);
	ez.print(name+" optimum point x="+x,name+" method");
	}
	else if(name=="Cubic polynomial optimisation")
    {
	double a[]=Text.readDoubleV("x_low,x_high = ");
	double x=ez.quadratic_polynomial_search(a[0],a[1]);
	ez.print(name+" optimum point x="+x,name+" method");
	}
	else if(name=="Newton optimisation")
    {
	double a[]=Text.readDoubleV("x0 = ");
	double x=ez.newton_search(a[0]);
	ez.print(name+" optimum point x="+x,name+" method");
	}
	else if(name=="Brent optimisation")
    {
	double a[]=Text.readDoubleV("x1,x2,x3 = ");
	double x=ez.brent_search(a[0],a[1],a[2]);
	ez.print(name+" optimum point x="+x,name+" method");
	}
	else if(name=="Gauss-Legendre Integration")
    {
	double a[]=Text.readDoubleV("xl,x2, = ");
	double x=ez.Gauss_Legendre_integral(a[0],a[1]);
	ez.print(name+" Integral ="+x,name+" method");
	}
	else if(name=="Gauss-Legendre Integration")
    {
	double a[]=Text.readDoubleV("xl,x2, = ");
	double x=ez.Gauss_Legendre_integral(a[0],a[1]);
	ez.print(name+" Integral ="+x,name+" method");
	}
	else if(name=="Adaptive Gauss-Lobatto Integration")
    {
	double a[]=Text.readDoubleV("xl,x2, = ");
	double x=ez.Gauss_Lobatto_integral(a[0],a[1]);
	ez.print(name+" Integral ="+x,name+" method");
	}
	else if(name=="Adaptive Simpson Integration")
    {
	double a[]=Text.readDoubleV("xl,x2, = ");
	double x=ez.Simpson_Integral(a[0],a[1]);
	ez.print(name+" Integral ="+x,name+" method");
	}
	else if(name=="Adaptive Gauss-Kronroad Integration")
    {
	double a[]=Text.readDoubleV("xl,x2, = ");
	double x=ez.Gauss_Kronroad_Integral(a[0],a[1]);
	ez.print(name+" Integral ="+x,name+" method");
	}
    else if(name=="nth order derivative")
    {
	double a[]=Text.readDoubleV("x, n(order of derivative) = ");
	int n=(int)a[1];
	double x=ez.derivative_n(a[0],n);
	ez.print(name+" Derivative df"+n+"/dx"+n+" at x="+a[0]+" = "+x,name+" method");
	}
    else if(name=="First order derivative")
    {
	double a[]=Text.readDoubleV("x = ");
	double x=ez.derivative(a[0]);
	ez.print(name+" Derivative df/dx at ="+a[0]+" = "+x,name+" method");
	}
	else if(name=="plot the function")
    {	ez.plot();}
    }
}