tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
36
Task/Numerical-integration/Logo/numerical-integration.logo
Normal file
36
Task/Numerical-integration/Logo/numerical-integration.logo
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
to i.left :fn :x :step
|
||||
output invoke :fn :x
|
||||
end
|
||||
to i.right :fn :x :step
|
||||
output invoke :fn :x + :step
|
||||
end
|
||||
to i.mid :fn :x :step
|
||||
output invoke :fn :x + :step/2
|
||||
end
|
||||
to i.trapezium :fn :x :step
|
||||
output ((i.left :fn :x :step) + (i.right :fn :x :step)) / 2
|
||||
end
|
||||
to i.simpsons :fn :x :step
|
||||
output ( (i.left :fn :x :step)
|
||||
+ (i.mid :fn :x :step) * 4
|
||||
+ (i.right :fn :x :step) ) / 6
|
||||
end
|
||||
|
||||
to integrate :method :fn :steps :a :b
|
||||
localmake "step (:b - :a) / :steps
|
||||
localmake "sigma 0
|
||||
; for [x :a :b-:step :step] [make "sigma :sigma + apply :method (list :fn :x :step)]
|
||||
repeat :steps [
|
||||
make "sigma :sigma + (invoke :method :fn :a :step)
|
||||
make "a :a + :step ]
|
||||
output :sigma * :step
|
||||
end
|
||||
|
||||
to fn2 :x
|
||||
output 2 / (1 + 4 * :x * :x)
|
||||
end
|
||||
print integrate "i.left "fn2 4 -1 2 ; 2.456897
|
||||
print integrate "i.right "fn2 4 -1 2 ; 2.245132
|
||||
print integrate "i.mid "fn2 4 -1 2 ; 2.496091
|
||||
print integrate "i.trapezium "fn2 4 -1 2 ; 2.351014
|
||||
print integrate "i.simpsons "fn2 4 -1 2 ; 2.447732
|
||||
Loading…
Add table
Add a link
Reference in a new issue