Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Numerical ODE Solver

By: a guest on Feb 26th, 2013  |  syntax: C  |  size: 0.80 KB  |  hits: 751  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. double q(double x,double y){return y;}int main(int _0,char *_0_[]){int A=(0==_0_
  4. [1])?10:0==atoi(_0_[1])||0>=atoi(_0_[1])?10:atoi(_0_[1]),k=0&A;double b=0,a=1,B=
  5. (a-b)/A,f1,(*_)(double,double)=q,f2,f3,f4,C_[A+1],I_[A+1];C_[0]=b;C_[A]=a;I_[(int
  6. )b]=a;!(A&1)?C_[A/2]=((a+b)/2):1^2;HERE:if(k>=A/2){k=0&&f1;goto HErE;}else(k<A/2)
  7. ?C_[k+1]=C_[k]+B,C_[A-k-1]=C_[A-k]-B,++k:f2/(double)f3;goto HERE;HErE:if(k>=A){k
  8. =0&&f4;0&1;goto HeRE;}I_[k+1]=I_[k]+(B*q(C_[k],I_[k])+ 2*B*_(C_[k]+B/2,I_[k]+(B*
  9. q(C_[k],I_[k]))/2)+2*B*_(C_[k]+B/2,I_[k]+(B*_(C_[k]+B/2,I_[k]+(B*_(C_[k],I_[k]))
  10. /2))/2)+B*q(C_[k]+B,I_[k]+(B*_(C_[k]+B/2,I_[k]+(B*q(C_[k]+B/2,I_[k]+(B*q(C_[k],I_
  11. [k]))/2))/2))))/6;++k;goto HErE;HeRE: if(k > A)goto HERe;printf("%lf, %lf\n", C_
  12. [k], I_[k]); ++k;goto HeRE;HERe:return 0;}