Professional Documents
Culture Documents
Zahidi Pratama - 200170263 - Tugas Metode Numerik A2
Zahidi Pratama - 200170263 - Tugas Metode Numerik A2
NIM : 200170263
UNIT : A2
SOAL NEWTON
SCREENSHOOT CODING PROGRAM BERJALAN
HASIL
PROGRAM
#include <stdio.h>
#include <math.h>
#include <conio.h>
main()
int n=0;
float x[100];
float e = 0.0005;
printf("\n");
printf("Nilai e = 0.0005\n\n");
printf("=============================================================
=====\n");
do
n++;
}while(abs(x[n-1]-x[n-2])>e);
printf("=============================================================
=====\n\n");
getch();
float Fungsi(float x)
return pow(x,2)+(3*x)-10;
float FungsiTurunan(float x)
return 2*x+3;
}
SOAL SECANT
SCREENSHOOT CODING PROGRAM BERJALAN
HASIL
PROGRAM
#include<stdio.h>;
#include<conio.h>;
#include<math.h>;
x1 = harga kedua
tol = toleransi
int max_iter;
float f(float x)
return 4*x*x - x - 5;
int main ()
int it;
printf("METODE SECANT");
printf("\n\n\n");
printf("Soal\n");
it = 0;
printf("\n");
printf("\n");
do
it = it +1;
epsilon = fabs(xb-x0);
printf("\n");
x0 = x1;
x1 = xb;
printf("\n");
printf("Toleransi terpenuhi\n\n");
printf("Hasil akhir=%g\n",xb);
printf("\n");
else
getch();
SOAL DIRECT
SCREENSHOOT CODING PROGRAM BERJALAN
HASIL
PROGRAM
#include <iostream>
#include <stdio.h>
#include <math.h>
double y;
y=pow(x,2)-exp(x)+8;
return y;
int main(){
int i=0,n;
puts("\t\t\t=====================");
puts("\t\t\tMETODE DIRECT");
puts("\t\t\t=====================\n");
scanf("%lf",&b);
scanf("%lf",&a);
scanf("%lf",&t);
scanf("%d",&n);
printf("\n\n");
fa = fungsi(a);
fb = fungsi(b);
if(fa*fb < 0)
printf("_____________________________________________________________________
______________________\n");
printf("_____________________________________________________________________
______________________\n");
do
i++;
atas = (fa*b)-(fb*a);
bawah = fa-fb;
c = atas/bawah;
fc = fungsi (c);
e = fabs(fc);
printf("\n%d\t",i);
printf("%.10lf\t",b);
printf("%.10lf\t",a);
printf("%.10lf\t",c);
printf("%.10lf\t",fa);
printf("%.10lf\t",fb);
printf("%.10lf\t",fc);
if((fc*fb)<0)
a = c;
fa = fc;
else
b = c;
fb = fc;
}while (e>t&&i<=n);
printf("_____________________________________________________________________
______________________\n");
else
{
return 0;