Hey, what's going on?

Archive for April, 2014

Numerical Methods in Pascal: Polynomial Root Finder

Posted by Syeilendra Pramuditya on April 29, 2014

program polinomial; {Mencari seluruh akar polinom}
{https://syeilendrapramuditya.wordpress.com}
uses crt;

const
  max = 100;
var
  n  : integer;
  a  : array[-1..max] of real;
  b  : array[-1..max] of real;
  iter,i,j,k   : longint;
  x0,x1,t,beda : real;

begin
     clrscr;
     writeln;
     writeln('           Program Polinom');
     writeln('           ===============');
     writeln;
     write('Masukan nilai tebakan awal (misal : 5) : ');
     iter := 0;
     readln(x0);
     write('Masukan orde polinomial : ');readln(n);
     { misal (x-1)*(x+1)*(x+2) = x^3+2*x^2-x-2 }
     writeln('Masukan satu per satu koefisien polinom');
     writeln('dimulai dari suku polinom dengan orde terendah (x pangkat nol)');
     for i := 0 to n do
     begin
       write('masukan koefisien ke ',i,' : ');
       readln(a[i]);
     end;
     writeln;
     repeat
       repeat
           iter := iter +1;
          b[n-1] := a[n];
          t := b[n-1];
          for j := n downto 2 do
          begin
            b[j-2] := b[j-1]*x0+a[j-1];
            t := t*x0+b[j-2];
          end;
          b[-1] := b[0]*x0 + a[0];
          x1 := x0 - b[-1]/t;
          beda := (x1-x0)/x0;
          x0 := x1;
       until (abs(beda)<1e-6)or (iter>1e6);
     n := n-1;
     writeln('nilai x',n+1, ' adalah',x1:10:4 );
     for k := 0 to n do a[k] := b[k];
     until (n<=0);
     readln;
end.
Advertisements

Posted in programming | Leave a Comment »

Home Layout and Interior Design

Posted by Syeilendra Pramuditya on April 28, 2014

Kebetulan lg ada waktu luang, iseng2 belajar bikin sketsa home layout n interior design, dan inilah hasilnya ūüėÄ hehehe..

Gambar2 lainnya bisa dilihat di album ini.

01

04

10

16

21

Gambar2 lainnya:

Home Design

 

 

Posted in whatever | Leave a Comment »

Numerical Methods in Pascal: Euler 2D

Posted by Syeilendra Pramuditya on April 28, 2014

Program Planetary_Motion;
{https://syeilendrapramuditya.wordpress.com}
{Gerak bulan mengitari bumi karena pengaruh gaya gravitasi}
{Data t[i],x[i],y[i],vx[i],vy[i] ditulis ke dalam file excel (D:\orbit.xls) }
{Data D:\orbit.xls tersebut kemudian diplot menggunakan Excel}
uses crt;
const GM = 3.986344692e14;
Type
 DataPlot = record
            dataT,dataX,dataY,dataVX,dataVY : real;
            end;
 ListData = array[0..1000] of DataPlot;
var t0,x0,y0,vx0,vy0,m,k,b,t,x,y,vx,vy,x12,y12,vx12,vy12,dt : real;
    i,N : integer;
    FileData : text;
    S:ListData;

Begin
clrscr;
writeln;
writeln('      Solusi Numerik PDB Orde 2 Terkopling');
writeln('              Kasus  Gerak  Bulan         ');
writeln;
writeln('Nilai konstanta yang digunakan dalam perhitungan :');
writeln('Massa Bumi  = 5.9742e24 Kg               ');
writeln('Massa Bulan = 7.3500e24 Kg               ');
writeln('d           = 3.844e5 Km                 ');
writeln('T           = 27.322 hari                ');
writeln('G           = 6.6726e-11 N*sqr(m)/sqr(Kg ');
writeln;
writeln('Nilai parameter (default) yang digunakan dalam perhitungan :');
writeln;
writeln('x0  = 3.844e5 ');
writeln('y0  = 0       ');
writeln('vx0 = 0       ');
writeln('vy0 = 32000   ');
writeln('dt  = 1       ');
writeln('N   = 1000    ');
writeln;
write('Masukan nilai x0,y0,vx0,vy0 pada t = 0  : ');readln(x0,y0,vx0,vy0);
write('Masukan parameter iterasi (dt dan N) : ');readln(dt,N);
writeln;
t0 := 0;
Assign(FileData,'D:\orbit.xls');
rewrite(FileData);
 S[0].DataT  := 0;
 S[0].DataX  := x0;
 S[0].DataY  := y0;
 S[0].DataVX := vx0;
 S[0].DataVY := vy0;
 writeln(FileData,'      t               x               y               vx               vy');
 writeln(FileData,s[0].dataT:20:5,s[0].dataX:20:5,s[0].DataY:20:5,s[0].DataVX:20:5,s[0].DataVY:20:5);
for i := 1 to N do
 begin
 x12  := x0 + (dt/2) * vx0;
 vx12 := vx0 - ( (GM * x0) /  ( exp(1.5 * ln( sqr(x0) + sqr(y0) ))) ) * (dt/2);
 y12  := y0 + (dt/2) * vy0;
 vy12 := vy0 - ( (GM * y0) /  ( exp(1.5 * ln( sqr(x0) + sqr(y0) ))) ) * (dt/2);
 x  := x0 + dt * vx12;
 vx := vx0 - ( (GM * x12)  /  (exp(1.5 * ln(sqr(x0) + sqr(y0) )))) * (dt);
 y  := y0 + dt * vy12;
 vy := vy0 - ( (GM * y12)  /  (exp(1.5 * ln(sqr(x0) + sqr(y0) )))) * (dt);
 t := t0 + dt;
 S[i].DataT  :=  t;
 S[i].DataX  :=  x;
 S[i].DataY  :=  y;
 S[i].DataVX := vx;
 S[i].DataVY := vy;
 writeln(FileData,s[i].dataT:20:5,s[i].dataX:20:5,s[i].DataY:20:5,s[i].DataVX:20:5,s[i].DataVY:20:5);
 t0  :=  t;
 x0  :=  x;
 y0  :=  y;
 vx0 := vx;
 vy0 := vy;
 end;
close(FileData);
writeln('Data t,x,y,vx,vy telah disimpan di D:\orbit.xls , silahkan buka file tersebut');
readln;
end.

Posted in programming | Leave a Comment »

Numerical Methods in Pascal: Modified Euler

Posted by Syeilendra Pramuditya on April 28, 2014

Program Modified_Euler;
{https://syeilendrapramuditya.wordpress.com}
uses crt;
var h,x0,y0,x12,y12,x,y : real;
    i,N : integer;

Function Fxy(x,y:real):real;
begin
Fxy := sqrt(x*x + y*y);
end;

Begin
clrscr;
write('Masukan nilai x0 dan y0 : ');readln(x0,y0);
write('Masukan nilai h dan N   : ');readln(h,N);
x:=x0;
for i := 1 to N do
 begin
 x12 := x0 + h/2;
 y12 := y0 + (h/2) * Fxy(x0,y0);
 x := x0 + h;
 y := y0 + h*Fxy(x12,y12);
 writeln('x = ',x:10:5,'    y = ',y:10:5);
 x0:=x;
 y0:=y;
 end;
readln;
end.

Posted in programming | Leave a Comment »

Numerical Methods in Pascal: Simple Euler

Posted by Syeilendra Pramuditya on April 28, 2014

Program Simple_Euler;
{https://syeilendrapramuditya.wordpress.com}
uses crt;
var h,x0,y0,x,y : real;
    i,N : integer;

Function Fxy(x,y:real):real;
begin
Fxy := sqrt(x*x + y*y);
end;

Begin
clrscr;
write('Masukan nilai x0 dan y0 : ');readln(x0,y0);
write('Masukan nilai h dan N   : ');readln(h,N);
x:=x0;
for i := 1 to N do
 begin
 x := x0 + h;
 y := y0 + h*Fxy(x0,y0);
 writeln('x = ',x:10:5,'    y = ',y:10:5);
 x0:=x;
 y0:=y;
 end;
readln;
end.

Posted in programming | Leave a Comment »

Bye XL. Hello Simpati!

Posted by Syeilendra Pramuditya on April 28, 2014

Akhirnya ganti juga.

Selama ini saya pakai XL untuk koneksi internet dari smartphone saya.

Tapi kualitasnya sangat mengecewakan, sinyalnya sering sekali hilang, kalaupun ada sinyal, koneksinya lambaaat bgt..

Entah kenapa saya kok tahan berbulan2 menggunakan XL, padahal hampir setiap saat saya menggerutu dan mengeluh karena sinyal XL yang hampir selalu hilang..

Minggu lalu seorang rekan merekomendasikan Simpati, katanya sinyalnya bagus dan koneksi internet juga relatif lancar.

So tanggal 26 kemarin saya beli perdana Simpati beserta pulsa seharga IDR 55k.

Sebagai perbandingan XL vs Simpati:

  • XL: Paket XmartPlan HotRod 3G+, 1.5GB/30 hari, IDR 49k
  • Simpati: Paket MaxiLoop 2.0GB/30 hari, IDR 49k

Hasilnya? Well, dua hari ini saya sengaja test kualitas data connection nya secara terus menerus, baik menggunakan browser, maps, apps, dan macam2 messenger (Whatsapp, LINE, BBM).

So far saya puas dengan kualitas koneksinya. Secara umum selalu lancar, sinyal juga hampir tidak pernah hilang.

Let’s see apa memang kualitas Simpati akan terus bagus seperti ini.

Bye XL, I’ll never miss you.

XL sebelah kiri (tidak ada sinyal), Simpati sebelah kanan (sinyal kuat)

XL sebelah kiri (tidak ada sinyal), Simpati sebelah kanan (sinyal kuat)

 

Posted in just a story | 2 Comments »

Numerical Methods in Pascal: Root Finding by Hybrid Bisection-NR

Posted by Syeilendra Pramuditya on April 25, 2014

Program Hybrid; {Bisection - Newton Rhapson Combined}
{https://syeilendrapramuditya.wordpress.com}
uses crt;
Function f(x:real):real;
begin
f := sqr(x) - 9;
end;

Function df(x:real):real;
begin
df:=2*x;
end;

Procedure BacaInput(var a,b:real);
begin
clrscr;
repeat
write('Masukan interval evaluasi : ');readln(a,b);
until(f(a)*f(b) < 0);
end;

Procedure Bisection(var a,b,newrootB:real);
begin
NewRootB := (a+b)/2;
IF (f(a)*f(newrootB) < 0) then
b:=newrootB
else
a := newrootB;
end;

Procedure NewtonRhapson(var b:real;var newrootNR:real);
begin
newrootNR := b - f(b)/df(b);
end;

Procedure TulisOutput(newrootB:real);
begin
writeln('Akar : ',newrootB:10:2);
end;

var a,b,c,d,newrootNR,newrootB : real;
    iterNR,iterBi,iter:integer;

Begin
iterNR := 0;iterBi:=0;
BacaInput(a,b);
c:=a;d:=b;
Repeat
begin
NewtonRhapson(b,newrootNR);
IF (newrootNR >= c) and (newrootNR <= d) then
  begin
  inc(iterNR);
  b := newrootNR;
  NewtonRhapson(b,newrootNR);writeln('Newton Rhapson');
  end
else
  begin
   inc(iterBi);
   writeln('Bisection');
   Bisection(a,b,NewrootB);
   end;
end;
Until (abs(f(newrootNR)) < 1e-6) OR (abs(f(newrootB)) < 1e-6)  OR (iter = 10000);
writeln;
if abs(f(newrootNR)) < abs(f(newrootB)) then
writeln('Akar = ',newrootNR:10:2)
else
writeln('Akar = ',newrootB:10:2);
writeln;
writeln('Iterasi Bisection      : ',iterBi);
writeln('Iterasi Newton Rhapson : ',iterNR);
writeln('Iterasi Total          : ',iterBi + iterNR);
readln;
end.

Posted in programming | Leave a Comment »

Numerical Methods in Pascal: Root Finding by Regula False (RF)

Posted by Syeilendra Pramuditya on April 25, 2014

Program RegulaFalse;
{https://syeilendrapramuditya.wordpress.com}
uses crt;
Function f(x:real):real;
begin
f := sqr(x) - 9;
end;

Procedure BacaInput(var a,b : real);
begin
repeat
write('Masukan batas kiri dan kanan : ');readln(a,b);
until (f(a)*f(b) < 0);
end;

Procedure Proses(a,b:real;var akar:real;var iter : integer);
var err : real;
begin
iter := 0;
repeat
inc(iter);
akar := a - f(a)*( (b-a) / (f(b) - f(a)) );
err := abs(f(akar));
if (f(a) * f(akar) < 0) then
b := akar
else
a := akar;
until (err < 1e-6) OR (iter = 10000);
end;

Procedure TulisOutput(akar:real);
begin
writeln('Akar = ',akar:10:3);
end;

var a,b,akar : real;
    iter : integer;

begin
clrscr;
BacaInput(a,b);
Proses(a,b,akar,iter);
TulisOutput(akar);
writeln('Iterasi = ',iter:10);
readln;
end.

Posted in programming | Leave a Comment »

Numerical Methods in Pascal: Root Finding by Newton-Rhapson (NR)

Posted by Syeilendra Pramuditya on April 25, 2014

Program NewtonRhapson;
{https://syeilendrapramuditya.wordpress.com}
uses crt;
Function f(x:real):real;
begin
f:=sqr(x) - 9;
end;

Function df(x:real):real;
begin
df:=2*x;
end;

Procedure BacaInput(var x:real);
begin
write('Masukan tebakan awal : ');readln(x)
end;

Procedure Proses(var x:real;var iter :integer);
var err:real;
begin
iter := 0;
repeat
 begin
 inc(iter);
 x := x - f(x)/df(x);
 end;
until(abs(f(x)) < 1e-6);
end;

Procedure TulisOutput(x1:real);
begin
writeln('Akarnya adalah : ',x1:10:2);
end;

var x,x1:real;
    iter : integer;
begin
clrscr;
BacaInput(x);
Proses(x,iter);
TulisOutput(x);
writeln('Iterasi = ',iter:10);
readln;
end.

Posted in programming | Leave a Comment »

Numerical Methods in Pascal: Root Finding by Bisection

Posted by Syeilendra Pramuditya on April 25, 2014

Program Bisection;
{https://syeilendrapramuditya.wordpress.com}
uses crt;
Function f(x:real):real;
begin
f := sqr(x) - 9;
end;

Procedure BacaInput(var a,b:real);
begin
repeat
write('Masukan batas kiri dan kanan : ');
Readln(a,b);
until (f(a)*f(b) < 0);
end;

Procedure Proses(a,b:real;var NewRoot:real;var iter :integer);

begin
iter:=0;
Repeat
begin
 inc(iter);
 NewRoot:=(a+b)/2;
 IF (f(a)*f(NewRoot) < 0) then
 b := NewRoot
 else
 a:=NewRoot;
 end;
until (abs(f(NewRoot)) < 1e-6) OR (iter = 10000);
end;

Procedure TulisAkar(NewRoot:real);
begin
writeln('Akar dari persamaan adalah : ',NewRoot:10:2);
end;

var a,b,NewRoot : real;
    iter:integer;
Begin
clrscr;
BacaInput(a,b);
Proses(a,b,NewRoot,iter);
TulisAkar(NewRoot);
writeln('Iterasi = ',iter:10);
readln;
end.

Posted in programming | Leave a Comment »

Returning Array from a Function in C++ (using pointer)

Posted by Syeilendra Pramuditya on April 17, 2014

/*
Returning Array from a Function in C++ (using pointer)
Source: http://stackoverflow.com/questions/3473438/c-return-array-in-a-function
*/
#include <iostream>
using namespace std;

int * fill_array(int array1[],int n){
int i;
    for (i=0;i<n;i++){
    array1[i]=3*i;
    }
return(array1);
}

int main(){
int const n=5;
int * array1;
int i,a[5];
array1=fill_array(a,n);

    for (i=0;i<n;i++){
    cout<<array1[i]<<endl;
    }

}

 

Posted in programming | Leave a Comment »

New Post

Posted by Syeilendra Pramuditya on April 11, 2014

New Post

Posted in whatever | Leave a Comment »

Revised Cheng-Todreas Correlations – Improvements in the Transition Flow Region

Posted by Syeilendra Pramuditya on April 8, 2014

Recently Cheng et al. published an article describing a revision to their correlations to improve the prediction of pressure drop coefficient in the transition flow region.

A computer code implementing the original correlations was developed and described in my previous post.

In the current post, I provide a modified code, in which the revision in the transition region has been incorporated.

 

Posted in nuclear engineering, software & simulation | Leave a Comment »

ask.fm

Posted by Syeilendra Pramuditya on April 7, 2014

Posted in whatever | Leave a Comment »

PEMILU, Parpol, Capres, Ingkar Janji Politik

Posted by Syeilendra Pramuditya on April 1, 2014

Pemilu legislatif dan pemilu presiden sudah di depan mata.

Ingat,

jangan pilih partai juara korupsi,

jangan pilih partai yang petingginya hobi menjual BUMN,

jangan pilih partai yang petingginya merelakan hutang2 koruptor BLBI,

jangan pilih partai feodal dan dinasti,

jangan pilih partai yang mengkultuskan individu,

jangan pilih partai yang menyuruh kadernya ingkar janji,

jangan pilih capres yang sudah ingkar janji,

jangan pilih capres yang bertuan tidak pada rakyat,

jangan pilih capres yang bertuan pada nyonya besar,

jangan pilih capres yang mencla-mencle,

jangan pilih capres boneka,

daan, jangan golput ya! ūüôā

Salam pemilih cerdas!

Posted in social & politics | Leave a Comment »