[過去ログ]
Rust part24 (1002レス)
Rust part24 http://mevius.5ch.net/test/read.cgi/tech/1716759686/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
342: デフォルトの名無しさん [sage] 2024/06/24(月) 23:33:41.46 ID:FIb4AZ4T >>328-329 なんかダサい https://paiza.io/projects/uc8gH6yNWCWKdQSYtqNREg pub fn f(x: i32) -> i32 { ( -2413f64*(x.pow(6) as f64)/120960f64 +739f64*(x.pow(5) as f64)/1260f64 -157991f64*(x.pow(4) as f64)/24192f64 +69551f64*(x.pow(3) as f64)/2016f64 -2691673f64*(x.pow(2) as f64)/30240f64 +88679f64*(x as f64)/840f64 -905f64/21f64 +0.5) as i32 } pub fn g(y: i32) -> i32 { ( 13f64*(y.pow(6) as f64)/120960f64 -(y.pow(5) as f64)/315f64 +1415f64*(y.pow(4) as f64)/24192f64 -1511f64*(y.pow(3) as f64)/2016f64 +144793f64*(y.pow(2) as f64)/30240f64 -3053f64*(y as f64)/280f64 +185f64/21f64 +0.5) as i32 } pub fn main() { let a = vec![(1, 2), (2, 1), (3, 3), (4, 10), (6, 4), (8, 8), (10, 6)]; for (x, _y) in &a { println!("{}, {}", x, f(*x)); } for (_x, y) in &a { println!("{}, {}", y, g(*y)); } } http://mevius.5ch.net/test/read.cgi/tech/1716759686/342
343: デフォルトの名無しさん [] 2024/06/24(月) 23:39:26.44 ID:FIb4AZ4T 係数はこっちで求めたでござる https://paiza.io/projects/YvPFB5g4cCOtCXz1wpA86g import sys, os from functools import reduce import sympy as sy def lc(a): x, y = sy.symbols('x y') p = 0 for i, (c, d) in enumerate(a): g = reduce(lambda s, t: (t[0], (s[1][0] * (1 if t[0] == i else (x - t[1][0])), 0)), enumerate(a), (-1, (1, 0))) f = g[1][0] p += d * f / f.subs(x, c) print(p) print(p.expand()) for c, d in a: print(p.subs(x, c), p.subs(x, c) == d) if __name__ == '__main__': lc([(1, 2), (2, 1), (3, 3), (4, 10), (6, 4), (8, 8), (10, 6)]) lc([(2, 1), (1, 2), (3, 3), (10, 4), (4, 6), (8, 8), (6, 10)]) http://mevius.5ch.net/test/read.cgi/tech/1716759686/343
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.036s