Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
36
Task/Euler-method/Odin/euler-method.odin
Normal file
36
Task/Euler-method/Odin/euler-method.odin
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package main
|
||||
|
||||
import "core:fmt"
|
||||
import "core:math"
|
||||
|
||||
ivp_euler ::proc(y:f32,step:i32,end:i32){
|
||||
|
||||
y:=y
|
||||
t:=i32(0)
|
||||
|
||||
for ;t<=end;t+=step{
|
||||
if(t%10==0){fmt.printfln("%.3f", y)}
|
||||
y+=f32(step)*cooling(f32(t),y)
|
||||
}
|
||||
}
|
||||
|
||||
cooling :: proc(t:f32,temp:f32)-> f32{
|
||||
return -0.07* (temp-20.0)
|
||||
}
|
||||
|
||||
analytic :: proc(){
|
||||
for t := 0; t <= 100; t += 10{
|
||||
fmt.printfln("%.3f",20+80*math.exp_f32(f32(-0.07)*f32(t)))
|
||||
}
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
fmt.println("Step: 2 Seconds")
|
||||
ivp_euler(100.0, 2,100)
|
||||
fmt.println("Step: 5 Seconds")
|
||||
ivp_euler(100.0, 5, 100)
|
||||
fmt.println("Step: 10 Seconds")
|
||||
ivp_euler(100.0, 10, 100)
|
||||
fmt.println("Analytic")
|
||||
analytic()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue