Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Euler-method/Scala/euler-method.scala
Normal file
29
Task/Euler-method/Scala/euler-method.scala
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
object App{
|
||||
|
||||
def main(args : Array[String]) = {
|
||||
|
||||
def cooling( step : Int ) = {
|
||||
eulerStep( (step , y) => {-0.07 * (y - 20)} ,
|
||||
100.0,0,100,step)
|
||||
}
|
||||
cooling(10)
|
||||
cooling(5)
|
||||
cooling(2)
|
||||
}
|
||||
def eulerStep( func : (Int,Double) => Double,y0 : Double,
|
||||
begin : Int, end : Int , step : Int) = {
|
||||
|
||||
println("Step size: %s".format(step))
|
||||
|
||||
var current : Int = begin
|
||||
var y : Double = y0
|
||||
while( current <= end){
|
||||
println( "%d %.5f".format(current,y))
|
||||
current += step
|
||||
y += step * func(current,y)
|
||||
}
|
||||
|
||||
println("DONE")
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue