Posts

Showing posts from September, 2024

Optimization: Interval Halving Method

Image
1. Interval Halving Method Algorithm in C #include<stdio.h> double myFun(double x); int main() {  double a, b, y, x, xm, x1, x2, fx1, fx2, fxm, L, t=0.01;  printf("Enter a:");  scanf("%lf",&a);   //Upper Bound  printf("Enter b:");  scanf("%lf",&b);    //Lower Bound  xm = (a + b)/2;  jump:  L = b-a;  x1 = a + (L/4);  x2 = b - (L/4);  printf("\n\na = %.2lf",a);  printf("\nb = %.2lf",b);  printf("\nx1 = %.2lf",x1);  printf("\nx2 = %.2lf",x2);  printf("\nxm = %.2lf",xm);  printf("\nL = %.2lf",L);  fx1 = myFun(x1);  printf("\nf(x1) = %.2lf",fx1);  fx2 = myFun(x2);  printf("\nf(x2) = %.2lf",fx2);  fxm = myFun(xm);  printf("\nf(xm) = %.2lf",fxm);  if(L > t)  {   if (fx1 < fxm)   {    a = a;    b = xm;    xm = x1;    got...

Popular posts from this blog

VLSI: 1-4 DEMUX (Demultiplexer) Dataflow Modelling with Testbench

VLSI: BCD to Excess 3 and Excess 3 to BCD Dataflow Modelling

VLSI: 4-1 MUX Dataflow Modelling with Testbench

1 to 4 DEMUX (Demultiplexer) Verilog CodeStructural/Gate Level Modelling with Testbench

Full Subtractor Verilog Code in Structural/Gate Level Modelling with Testbench