fork download
  1. #include <stdio.h>
  2. #define inverse_step_size 10
  3.  
  4. double differential_function(double y)
  5. {
  6. return (1-y)/15;
  7. }
  8.  
  9. double slope(double y)
  10. {
  11. double k[4];
  12. k[0]=differential_function(y);
  13. k[1]=differential_function(y+k[0]/(2*inverse_step_size));
  14. k[2]=differential_function(y+k[1]/(2*inverse_step_size));
  15. k[3]=differential_function(y+k[2]/inverse_step_size);
  16.  
  17. return (k[0]+2*k[1]+2*k[2]+k[3])/6;
  18. }
  19.  
  20. int main(void)
  21. {
  22. int i,j;
  23. double x=0,y=0;
  24. printf("(x,y)=(%3.0f,%16.16f)\n",x,y);
  25. for(j=0;j<100;j++) {
  26. x = 1.0 + (double)j;
  27. for(i=0;i<inverse_step_size;i++) {
  28. y += slope(y)/inverse_step_size;
  29. }
  30. printf("(x,y)=(%3.0f,%16.16f)\n",x,y);
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0s 1832KB
stdin
Standard input is empty
stdout
(x,y)=(  0,0.0000000000000000)
(x,y)=(  1,0.0644930149673499)
(x,y)=(  2,0.1248266809551210)
(x,y)=(  3,0.1812692469193077)
(x,y)=(  4,0.2340716616319704)
(x,y)=(  5,0.2834686894222572)
(x,y)=(  6,0.3296799539599224)
(x,y)=(  7,0.3729109147220998)
(x,y)=(  8,0.4133537804847892)
(x,y)=(  9,0.4511883639005230)
(x,y)=( 10,0.4865828809617423)
(x,y)=( 11,0.5196946989043704)
(x,y)=( 12,0.5506710358768284)
(x,y)=( 13,0.5796496154852881)
(x,y)=( 14,0.6067592791253268)
(x,y)=( 15,0.6321205588224685)
(x,y)=( 16,0.6558462131285117)
(x,y)=( 17,0.6780417284562847)
(x,y)=( 18,0.6988057880818156)
(x,y)=( 19,0.7182307108991344)
(x,y)=( 20,0.7364028618784562)
(x,y)=( 21,0.7534030360526796)
(x,y)=( 22,0.7693068177394371)
(x,y)=( 23,0.7841849165958332)
(x,y)=( 24,0.7981034819999980)
(x,y)=( 25,0.8111243971572279)
(x,y)=( 26,0.8233055542383342)
(x,y)=( 27,0.8347011117734890)
(x,y)=( 28,0.8453617354459678)
(x,y)=( 29,0.8553348233563761)
(x,y)=( 30,0.8646647167589077)
(x,y)=( 31,0.8733928972065859)
(x,y)=( 32,0.8815581709820143)
(x,y)=( 33,0.8891968416336313)
(x,y)=( 34,0.8963428713845830)
(x,y)=( 35,0.9030280321318497)
(x,y)=( 36,0.9092820467069836)
(x,y)=( 37,0.9151327210265173)
(x,y)=( 38,0.9206060677195924)
(x,y)=( 39,0.9257264217824694)
(x,y)=( 40,0.9305165487741313)
(x,y)=( 41,0.9349977460340243)
(x,y)=( 42,0.9391899373719634)
(x,y)=( 43,0.9431117616511989)
(x,y)=( 44,0.9467806556584942)
(x,y)=( 45,0.9502129316296635)
(x,y)=( 46,0.9534238497752521)
(x,y)=( 47,0.9564276861288182)
(x,y)=( 48,0.9592377960194745)
(x,y)=( 49,0.9618666734508925)
(x,y)=( 50,0.9643260066507788)
(x,y)=( 51,0.9666267300377951)
(x,y)=( 52,0.9687790728369771)
(x,y)=( 53,0.9707926045597965)
(x,y)=( 54,0.9726762775510790)
(x,y)=( 55,0.9744384667919410)
(x,y)=( 56,0.9760870071357169)
(x,y)=( 57,0.9776292281424274)
(x,y)=( 58,0.9790719866666692)
(x,y)=( 59,0.9804216973438128)
(x,y)=( 60,0.9816843611100535)
(x,y)=( 61,0.9828655918831194)
(x,y)=( 62,0.9839706415222581)
(x,y)=( 63,0.9850044231784801)
(x,y)=( 64,0.9859715331388745)
(x,y)=( 65,0.9868762712621181)
(x,y)=( 66,0.9877226600960377)
(x,y)=( 67,0.9885144627622232)
(x,y)=( 68,0.9892551996872072)
(x,y)=( 69,0.9899481642546013)
(x,y)=( 70,0.9905964374477786)
(x,y)=( 71,0.9912029015482056)
(x,y)=( 72,0.9917702529503264)
(x,y)=( 73,0.9923010141499784)
(x,y)=( 74,0.9927975449596371)
(x,y)=( 75,0.9932620530003569)
(x,y)=( 76,0.9936966035170539)
(x,y)=( 77,0.9941031285607735)
(x,y)=( 78,0.9944834355787642)
(x,y)=( 79,0.9948392154505514)
(x,y)=( 80,0.9951720500057422)
(x,y)=( 81,0.9954834190569833)
(x,y)=( 82,0.9957747069793426)
(x,y)=( 83,0.9960472088653651)
(x,y)=( 84,0.9963021362831740)
(x,y)=( 85,0.9965406226632105)
(x,y)=( 86,0.9967637283375698)
(x,y)=( 87,0.9969724452543333)
(x,y)=( 88,0.9971677013878599)
(x,y)=( 89,0.9973503648646446)
(x,y)=( 90,0.9975212478230872)
(x,y)=( 91,0.9976811100243331)
(x,y)=( 92,0.9978306622302415)
(x,y)=( 93,0.9979705693634958)
(x,y)=( 94,0.9981014534639111)
(x,y)=( 95,0.9982238964540793)
(x,y)=( 96,0.9983384427266498)
(x,y)=( 97,0.9984456015647490)
(x,y)=( 98,0.9985458494062990)
(x,y)=( 99,0.9986396319623033)
(x,y)=(100,0.9987273661985197)