Tuesday, October 4, 2011
Monday, October 3, 2011
Algoritma Metode Bagi dua / Bisection
Algoritma Metode Bagi dua / Bisection
1. Untuk n = 0, 1, 2 …… sampai selesai ß kriteria pemutusan
2. ambil m = (an + bn )/2 iterasi (bil. kecil tertentu)
3. Kalau f (an) f (m) < 0, ambil an+1 = an ; bn+1 = m
4. Jika f (an) f (m)>0 ambil an+1 = m ; bn+1 = bn
5. Jika f(an) f(bn) = 0 maka an dan bn merupakan akarnya, hentikan perhitungan
f (x) punya akar dalam [an+1, bn+1]
Apabila ea sudah lebih kecil dari ketelitian yang diinginkan, maka perhitungan dihentikan.
Dari algoritma diatas dapat diturunkan program metode bisection, ada dua buah program:
1. program utama disimpan dengan nama bisection.m
2. program fungsi disimpan dengan nama fbi.m(program ini akan dipanggil oleh program utama)
Program utama dengan nama Bisection.m
%Nama File Bisection.m
clear;
clc;
galat = 0.001;
bawah = input('Batas Bawah : ');
atas = input('Batas Atas : ');
nilai = 1;
no = 0;
m0=bawah;
clc;
fprintf ('Taksiran batas bawah : %5.3f\n', bawah);
fprintf ('Taksiran batas atas : %5.3f\n', atas);
fprintf ('=========================\n');
fprintf ('Iterasi (bawah+atas)/2 Galat Interval\n');
fprintf ('=========================\n');
while nilai> galat
no = no +1;
fbawah=feval('fbi',bawah);
m=(bawah+atas)/2;
ftengah=feval('fbi',m);
if fbawah*ftengah==0
disp('m adalah akarnya');
elseif fbawah*ftengah<0
atas=m;
else
bawah=m;
end
nilai=abs(m0-m);
fprintf (' %3d %8.5f %8.5f [%8.5f ; %8.5f]\n', no, m, nilai, bawah, atas);
m0=m;
end
fprintf ('==========================\n');
fprintf ('Pada iterasi ke-%1d, Selisih Interval < %5.3f\n', no, galat);
fprintf ('jadi, akar persamaannya adalah %7.5f\n', m);
fungsi yang diberi nama fbi.m
%Nama Fungsi fbi.m
function [y]=f(x)
y=x^3+x^2-8*x-10;
Labels:
numeric
Sunday, October 2, 2011
Inroduction Wireless Markup Language
Wireless Markup Language (WML) adalah salah satu script Markup Language untuk aplikasi WAP. Markup Language sendiri adalah bahasa penandaan yang digunakan untuk memberi ciri khas pada sebuah dokumen atau teks yang ingin ditonjolkan. Pemberian tanda dilakukan dengan cara meletakan tag di antara dokumen atau teks.
- Menulis Dokumen Prolog
Langkah pertama dalam menulis script WML adalah menulis dokumen prolog pada script tersebut. Sebagian besar dokumen prolog pada script WML memiliki struktur seperti dibawah ini:
< ? xml version=”1.0”?>
<!DOCTYPE wml PUBLIC “-//WAPFORUM//DTD EML 1.2//EN” “http://www.wapforum.org//DTD/wml_1.2.xml”>
Dokumen prolog diatas, untuk mengenal latar belakang dan sejarah WML. Script WML bukanlah script yang diciptakan secara mandiri. Script ini merupakan hasil dari bahasa Markup lainya, yaitu XML (Extensiable Markup Language). Dari dokumen diatas menggunakan versi XML 1.0.
Sedangkan pada baris kedua merupakan sebuah pernyataan tentang isi dari Document Type Definition. Document DTD ini merupakan spesifikasi WML, yaitu spesifikasi yang berisi aturan bagaimana menulis dan meletakan struktur tag dan elemen dalam WML yang benar. Untuk kasus ini digunakan document DTD yang dibuat oleh WAO Forum dimana dapat melihat seluruh isi aturan tentang peletakan tag dan elemen yang benar pada URL diatas.
- Membuat Deck
Langkah kedua untuk memulai penulisan script WML adalah membuat deck. Didalam script WML, hanya perlu menciptakan satu buah deck. Untuk membuat deck, cukup menuliskan tag <wml> seperti dibawah ini:
< ? xml version=”1.0”?>
<!DOCTYPE wml PUBLIC “-//WAPFORUM//DTD EML 1.2//EN” “http://www.wapforum.org//DTD/wml_1.2.xml”>
<wml>
……………..
</wml>
- Membuat Card
Langkah ketiga adalah membuat card. Card dibentuk oleh pasangan tag<card> dan </card>. Satu buah script WML bisa memuat beberapa card. untuk menulis card, cukuplah dengan meletakan tanda <card> dan </card> diantara deck, seperti ini:
< ? xml version=”1.0”?> <!DOCTYPE wml PUBLIC “-//WAPFORUM//DTD EML 1.2//EN” “http://www.wapforum.org//DTD/wml_1.2.xml”>
<wml>
<card>
<p> Selamat Datang DI PROGRAM PERTAMA</p>
</card>
</wml>
Diantara tag <card> dan </card> berisi elemen-elemen dan tag-tag lain yang bertanggung jawab untuk mengatur bagaimana informasi yang ada didalam script WML tersebut ditampilkan di layar monitor ponsel.
- Menulis Beberapa Card
Penulisan beberapa card pada satu deck adalah seperti berikut ini :
<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="salam">
<p align = "center">
Info Hotel
<a href="#menu">
<br/>Menu</a></p>
</card>
<card id="menu">
<p align="center">
Menu Hotel Yogyakarta
<br/>1. Hotel Sheraton
<br/>2. Hotel Garuda</p>
</card>
</wml>
Labels:
WML
Upload files to the server using php
This time we will discuss uploading files using PHP. It would be nice if we as users of the website, can upload pictures, documents or videos to our web site. This article will explain how to upload files with PHP keserver us. PHP makes things easier in handling file uploads. To create a form upload, make sure we include the attribute enctype = "multipart / form-data", and make sure methodnya is post. Okay we just see the following HTML code:
<Form method = "post" action ="<?=$ PHP_SELF?> "Enctype =" multipart / form-data ">
<input type="file" name="myfile">
<input type="submit" name="Submit" value="Submit">
</ Form>
As we see, we give a name to upload "myfile". The name is very important, because when a file has been uploaded then the file is automatically given a unique name and stored in a temporary directory. Of course the url path to the file can be accessed, because it will automatically show up global variables, which have the same name with which we uploaded, in this case myfile. There will be four new variables which are all preceded by myfile and followed by an underscore (underscore), namely:
<input type="file" name="myfile">
<input type="submit" name="Submit" value="Submit">
</ Form>
As we see, we give a name to upload "myfile". The name is very important, because when a file has been uploaded then the file is automatically given a unique name and stored in a temporary directory. Of course the url path to the file can be accessed, because it will automatically show up global variables, which have the same name with which we uploaded, in this case myfile. There will be four new variables which are all preceded by myfile and followed by an underscore (underscore), namely:
• $ myfile. This variable contains the location information file on the server.
• $ myfile_name. The original file name when it was still dikomputer clients.
• $ myfile_size. The size of the file (in bytes).
• $ myfile_type. The file type.
Simple Upload
We will try to upload the following examples, save with the name upload.php:
<html>
<head>
<title> Upload file </ title>
</ Head>
<body>
<?
if (isset ($ upload)) {
echo "File Location: $ myfile <br>";
echo "File Name: $ myfile_name <br>";
echo "Size: $ myfile_size byte <br>";
echo "File Type: $ myfile_type <br>";
copy ($ myfile, "$ myfile_name") or die ("Failed to upload");
}
?>
<Form enctype = "multipart / form-data" action ="<?=$ PHP_SELF?> "Method =" post ">
<input type="file" name="myfile"> <br>
<input type="submit" value="upload" name="upload">
</ Form>
</ Body>
</ Html>
When the upload button is pressed, then the url path to the file will be stored in the variable $ myfile, and we show dibrowser. Also displayed the name of the file that is stored in the variable $ myfile_name, the file size in the variable $ myfile_size and file type in the variable $ myfile_type.
We use the function copy( ), to move files from your computer's temporary directory on our server. Function copy( ) takes two arguments namely the location of the file and the new location on the server. If we want to upload to a folder on the server, (let's say we save the image difolder) then we need to convert it to: copy ($ myfile, "images / $ myfile_name").
• $ myfile_name. The original file name when it was still dikomputer clients.
• $ myfile_size. The size of the file (in bytes).
• $ myfile_type. The file type.
Simple Upload
We will try to upload the following examples, save with the name upload.php:
<html>
<head>
<title> Upload file </ title>
</ Head>
<body>
<?
if (isset ($ upload)) {
echo "File Location: $ myfile <br>";
echo "File Name: $ myfile_name <br>";
echo "Size: $ myfile_size byte <br>";
echo "File Type: $ myfile_type <br>";
copy ($ myfile, "$ myfile_name") or die ("Failed to upload");
}
?>
<Form enctype = "multipart / form-data" action ="<?=$ PHP_SELF?> "Method =" post ">
<input type="file" name="myfile"> <br>
<input type="submit" value="upload" name="upload">
</ Form>
</ Body>
</ Html>
When the upload button is pressed, then the url path to the file will be stored in the variable $ myfile, and we show dibrowser. Also displayed the name of the file that is stored in the variable $ myfile_name, the file size in the variable $ myfile_size and file type in the variable $ myfile_type.
We use the function copy( ), to move files from your computer's temporary directory on our server. Function copy( ) takes two arguments namely the location of the file and the new location on the server. If we want to upload to a folder on the server, (let's say we save the image difolder) then we need to convert it to: copy ($ myfile, "images / $ myfile_name").
Labels:
PHP
Saturday, October 1, 2011
Advantages and Disadvantages of Bisection method.
Advantages:
- The method is quite simple
- Easy to make the program
- A small error rate
- Always be obtained root
weakness
- Convergence is rather slow
- Convergence is linear
- If enough roots in the interval, then the result is unpredictable
- The method is quite simple
- Easy to make the program
- A small error rate
- Always be obtained root
weakness
- Convergence is rather slow
- Convergence is linear
- If enough roots in the interval, then the result is unpredictable
Labels:
numeric
Bisection method of numerically
Often called the method of Bolzano. If there are signs of change in function on the interval, then the function value is calculated at the midpoint. Then the root location is determined at the midpoint of the interval where the sign changes.
The first stage of this process is to establish the value of a and b as a boundary segment of the value of unknown function. Limits a and b give you a price for the function f (x) for x = a and x = b. The next step is to check whether f (a). F (b) <0.
If these conditions are fulfilled, then there is the function of roots in this segment. If not, return must set the value of a and b so that in accordance with the multiplication of f (a) x f(b) <0.
With the formula m = (a + b) / 2, checked whether the absolute value of f (m) <10-6 (margin of error deviation). If true, the value of x = m is the solution sought. If not met, set new limits by changing the value of b = m if f (a) * f (m) <0, and replace if m = f (a) xf (m)> 0; the process of discovering new m done with the procedure has been described.
Looking back to the drawing below:
given f (x) = 0; continuous nature and limits of the interval [a, b], f (a) f (b) <= 0
The first stage of this process is to establish the value of a and b as a boundary segment of the value of unknown function. Limits a and b give you a price for the function f (x) for x = a and x = b. The next step is to check whether f (a). F (b) <0.
If these conditions are fulfilled, then there is the function of roots in this segment. If not, return must set the value of a and b so that in accordance with the multiplication of f (a) x f(b) <0.
With the formula m = (a + b) / 2, checked whether the absolute value of f (m) <10-6 (margin of error deviation). If true, the value of x = m is the solution sought. If not met, set new limits by changing the value of b = m if f (a) * f (m) <0, and replace if m = f (a) xf (m)> 0; the process of discovering new m done with the procedure has been described.
Looking back to the drawing below:
given f (x) = 0; continuous nature and limits of the interval [a, b], f (a) f (b) <= 0
Figure 1. Determination of the midpoint m interval Bisection method
Labels:
numeric