Breaking News
Loading...
Sunday, 25 May 2014

Metode Euler, Heun, dan MidPoint Menggunakan PHP (Free SourceCode)

18:32
<form action="#">
    Masukkan Nilai H : <input type="text" name="h" value="<?php echo @$_GET['h']; ?>" /> <br />
    Masukkan Nilai X<sub>0</sub> : <input type="text" name="x0" value="<?php echo @$_GET['x0']; ?>" /> <br />
    Masukkan Nilai X<sub>1</sub> : <input type="text" name="x1" value="<?php echo @$_GET['x1']; ?>" /> <br />
    Masukkan Nilai Y<sub>0</sub> : <input type="text" name="y" value="<?php echo @$_GET['y']; ?>" /> <br />
    Masukkan Persamaan F(x<sub>i</sub>,y<sub>i</sub>) : <input type="text" name="p" value="<?php echo @$_GET['p']; ?>" /> <br />
    <input type="submit" value="Hitung" name="hitung" /> <br />
</form>

<table border="1" width="100%" style="text-align:center">
    <tr>
        <th>Iterasi</th><th>Persamaan</th><th>Metode EULER</th><th>Metode HEUN</th><th>Metode MIDPOINT <sup>i + 1/2</sup></th><th>Metode MIDPOINT <sup>i</sup></th>
    </tr>
    <?php
        class tugas{
            protected $h = null;
            protected $x0 = null;
            protected $x1 = null;
            protected $x = null;
            protected $y = null;
            protected $p = null;
            protected $yH = null;
            protected $yP = null;
            protected $yP1 = null;
            protected $persamaan = null;
            protected $rumusEuler = null;
            protected $rumusHeun = null;
            protected $midPoint = null;
           
            public function metodeEulerHeunMid($h,$x0,$x1,$y,$p){
                $this->h = $h;
                $this->x0 = $x0;
                $this->x1 = $x1;
                $this->p = $p;
                $this->y = $this->yH = $this->yP = $y;
                $this->hitung();
            }
            public function n(){
                return ($this->x1-$this->x0)/$this->h;
            }
            public function persamaan($x,$y){
                return $this->persamaan = -2*(pow($x,3))+12*(pow($x,2))-20*$x+8.5+$y;    /* Persamaan f(x,y) = -2x^3+12x^2-20x_8.5 + y*/
            }
            public function predictorEuler($x,$y,$h){
                $this->rumusEuler = $y + $h*($this->persamaan($x,$y));    /* Rumus EULER */
                $this->y = $this->rumusEuler;
            }
            public function corrector($x,$y,$h){
                $this->rumusHeun = $y + ($h/2)*($this->persamaan($x,$y)+$this->persamaan($x+$this->h,$this->y));    /* Rumus HEUN */
                $this->yH = $this->rumusHeun;
            }
            public function midPoint($x,$y,$h){
                $this->midPoint1 = $y + ($h/2)*($this->persamaan($x,$y));    /* Rumus midPoint i + 1/2 */
                $this->yP1 = $this->midPoint1;
                $this->midPoint = $y + $h*($this->persamaan($x+($x/2),$this->yP1));    /* Rumus midPoint i */
                $this->yP = $this->midPoint;
            }
            public function hitung(){
                $no = -1;
                for($i=$this->x0;$i<=$this->x1+$this->h;$i+=$this->h){
                    $no++;
                    $this->predictorEuler($i,$this->y,$this->h);
                    $this->corrector($i,$this->yH,$this->h);
                    $this->midPoint($i,$this->yP,$this->h);
                    echo "
                        <tr>
                            <td>Ke-$no => X = {$i}</td><td>f(x,y) = {$this->p}</td><td>{$this->rumusEuler}</td><td>{$this->rumusHeun}</td><td>{$this->midPoint1}</td><td>{$this->midPoint}<td></td>
                        </tr>
                    ";
                }
            }
        }
       
        $kerjakan = new tugas();
        if(isset($_GET['hitung'])){
            $kerjakan->metodeEulerHeunMid($_GET['h'],$_GET['x0'],$_GET['x1'],$_GET['y'],$_GET['p']);
        }else{
            // Don't Anything Here....:-)
        }
    ?>
</table>
Next
This is the most recent post.
Older Post
Comments
0 Comments

0 comments:

Post a Comment

 
Toggle Footer