Numerical integration: Difference between revisions
Content added Content deleted
Line 2,597: | Line 2,597: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
{{works with|Julia|0.6}} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
for i in 1:(n-1) |
for i in 1:(n-1) |
||
s += f(a + h*i + h/2) + |
s += f(a + h * i + h / 2) + f(a + h * i) / 2 |
||
end |
end |
||
h/6 * (f(a) + f(b) + 4*s) |
return h/6 * (f(a) + f(b) + 4*s) |
||
end |
end |
||
rst = |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
@show rst</lang> |
|||
{{out}} |
{{out}} |
||
⚫ | |||
<pre> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
</pre> |
|||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |