Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
26
Task/Euler-method/DuckDB/euler-method.duckdb
Normal file
26
Task/Euler-method/DuckDB/euler-method.duckdb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Declaration for the sake of euler_table()
|
||||
create or replace function cooling(x,y) as NULL;
|
||||
|
||||
# Euler method assuming cooling/2 is available
|
||||
create or replace function euler_table(x_start, y_start, x2, h) as table (
|
||||
with recursive cte as (
|
||||
select x_start::DOUBLE as x, y_start::DOUBLE as y
|
||||
union all
|
||||
select x + h as x,
|
||||
y + h*cooling(x, y)
|
||||
from cte
|
||||
where (x < x2 and x_start < x2) or
|
||||
(x > x2 and x_start > x2)
|
||||
)
|
||||
from cte
|
||||
);
|
||||
|
||||
create or replace function euler(x_start, y_start, x2, h) as (
|
||||
select last(y order by x) from euler_method(x_start, y_start, x2, h)
|
||||
);
|
||||
|
||||
## Example:
|
||||
create or replace function cooling(x,y) as
|
||||
-0.07 * (y - 20);
|
||||
|
||||
select h, euler(0,100, 100, h) from unnest([1,2,5,10,20]) _(h);
|
||||
Loading…
Add table
Add a link
Reference in a new issue