You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with
recursive newton as (
-- Initial stepselect0as n, 1+0.5* (N -1) as x, N as tgt from unnest(generate_array(2, 1000)) as N
union all-- Update stepselect
n +1
, x - (x * x - tgt) / (2* x)
, tgt
from newton
where-- Maximum recursive depth
n <98-- tolerance errorand abs(x * x - tgt) > 1e-06
)
select*, tgt - x*x as e from newton
qualify n =max(n) over (partition by tgt)
order by tgt
The text was updated successfully, but these errors were encountered:
BigQueryでNewton法
Newton法では次の漸化式で、Nの平方根を求めることができる:
漸化式で表されるものは、WITH RECURSIVEで表すことができる.
この実装は次のようになる。
このSQLにおいては、 2~1000までの数字の平方根を求めることができる。
The text was updated successfully, but these errors were encountered: