///Numerical Analysis
// 
//  
// Secant method with one root estimation 
// Linear difference formula 
//  

import java.util.*;
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import javax.swing.*;

//============= function definition ================

class fb extends f_x
{
   public double func (double t)
   { return 75.0*Math.exp(-1.5*t)+20*Math.exp(-0.075*t)-15;}
}

public class NA8
{

public static double secant(f_x f,double x)
{
int nmax=10;
double tolerance=1.0e-10;
double fx,dfx;
double dx=0.01;
for(int i=0;i<nmax;i++)
{
  fx=f.func(x);
  dfx=f.dfunc(x);
  x-=fx/dfx;
  System.out.println("fx="+fx+"dfx="+dfx+"x="+x);
  if(Math.abs(fx)<tolerance) { return x;}
}
JOptionPane.showMessageDialog(null,"Warning : Maximum number of iteration is exceeded \n"+
   " çözüm geçerli olmıyabilir","MAXİMUM ITERATION NUMBER WARNING",JOptionPane.WARNING_MESSAGE);
return x;
}

     public static void main (String args[])  
     {
	 fb f=new fb();
	 f.setOrder(1);
	 f.coef_out();
     double x0;
     x0=Double.parseDouble(JOptionPane.showInputDialog(" First estimation for the root : "));
     double r= secant(f,x0);
     JOptionPane.showMessageDialog(null," the root : "+r+"\nFunction value : "+f.func(r),
     "root of the function by Secant method : ",JOptionPane.PLAIN_MESSAGE);
     } 
}