Created
May 21, 2017 03:06
-
-
Save muhghazaliakbar/d28fceccb3d557d2ebb8c59ed4df2d38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Foundation\Bus\DispatchesJobs; | |
use Illuminate\Routing\Controller as BaseController; | |
use Illuminate\Foundation\Validation\ValidatesRequests; | |
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; | |
class Controller extends BaseController | |
{ | |
use AuthorizesRequests, DispatchesJobs, ValidatesRequests; | |
public function linearNaik($a, $b, $x) | |
{ | |
if ($x <= $a) { | |
$result = 0; | |
} else if ($x == $b) { | |
$result = 1; | |
} else if ($x >= $a && $x <= $b) { | |
$result = ($x - $a)/($b - $a); | |
} else { | |
$result = 'Input Salah'; | |
} | |
return $result; | |
} | |
public function linearTurun($a, $b, $x) | |
{ | |
if ($x >= $b) { | |
$result = 0; | |
} else if ($x >= $a && $x <= $b) { | |
$result = ($b - $x)/($b - $a); | |
} else { | |
$result = 'Input Salah'; | |
} | |
return $result; | |
} | |
public function segitiga($a, $b, $c, $x) | |
{ | |
if ($x <= $a || $x >= $c) { | |
$result = 0; | |
} else if ($x >= $a && $x <= $b) { | |
$result = ($x - $a)/($b - $a); | |
} else if ($x >= $b && $x <= $c) { | |
$result = ($b - $x)/($c - $b); | |
} else { | |
$result = 'Input Salah'; | |
} | |
return $result; | |
} | |
public function trapesium($a, $b, $c, $d, $x) | |
{ | |
if ($x <= $a || $x >= $d) { | |
$result = 0; | |
} else if ($x >= $a && $x <= $b) { | |
$result = ($x - $a)/($b - $a); | |
} else if ($x >= $b && $x <= $c) { | |
$result = 1; | |
} else if ($x >= $c && $x <= $d){ | |
$result = ($d - $x)/($d - $c); | |
} else { | |
$result = 'Input Salah'; | |
} | |
return $result; | |
} | |
public function bentukBahu($a, $b, $c, $d, $x) | |
{ | |
if (($x >= 0 && $x <= $a) || ($x >= $c && $x <= $d)) { | |
$result = 1; | |
} else if ($x >= $a && $x <= $b) { | |
$result = ($b - $x)/($b - $a); | |
} else if ($x >= $b && $x <= $c) { | |
$result = ($x - $b)/($c - $b); | |
} else { | |
$result = 'Input Salah'; | |
} | |
return $result; | |
} | |
public function sigmoidPertumbuhan($a, $b, $c, $x) | |
{ | |
if ($x <= $a) { | |
$result = 0; | |
} else if ($x >= $a && $x <= $b) { | |
$result = 2 * (pow(($x - $a), 2)/pow(($c - $a), 2)); | |
} else if ($x >= $b && $x <= $c) { | |
$result = 1 - 2 * (pow(($x - $a), 2)/pow(($c - $a), 2)); | |
} else if ($x >= $c) { | |
$result = 1; | |
} else { | |
$result = 'Input Salah'; | |
} | |
return $result; | |
} | |
public function sigmoidPenyusutan($a, $b, $c, $x) | |
{ | |
if ($x <= $a) { | |
$result = 0; | |
} else if ($x >= $a && $x <= $b) { | |
$result = 1 - 2 * (pow(($x - $a), 2)/pow(($c - $a), 2)); | |
} else if ($x >= $b && $x <= $c) { | |
$result = 2 * (pow(($x - $a), 2)/pow(($c - $a), 2)); | |
} else if ($x >= $c) { | |
$result = 1; | |
} else { | |
$result = 'Input Salah'; | |
} | |
return $result; | |
} | |
public function pi($a, $b, $c, $x) | |
{ | |
if ($x <= $a && $x >= $c) { | |
$result = 0; | |
} else if ($x >= $b) { | |
$result = 1; | |
} else if ($x >= $a && $x <= $b) { | |
$result = (1 - 2) * (($b - $x) / ($b - $a)) * (($b - $x) / ($b - $a)); | |
} else if ($x >= $b && $x <= $c) { | |
$result = (2 * (($c - $x) / ($c - $b)) * (($c - $x) / ($c) - $b)); | |
} else { | |
$result = 'Input Salah'; | |
} | |
return $result; | |
} | |
public function beta($a, $b, $c, $x) | |
{ | |
if ($x <= $c) { | |
$result = 2 * ($c - $b); | |
} else if ($x > $c) { | |
$result = 2 * (sqrt($c - $x) / ($c - $a)); | |
} else { | |
$result = 'Input Salah'; | |
} | |
return $result; | |
} | |
public function gauss($a, $b, $c, $x) | |
{ | |
if ($x <= $c) { | |
$result = 2 * ($c - $b); | |
} else if ($x > $c) { | |
$result = 2 * (sqrt($c - $x) / ($c - $a)); | |
} else { | |
$result = 'Input Salah'; | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment