gpt4 book ai didi

Scheme Lisp 3 × 3 矩阵的行列式

转载 作者:太空宇宙 更新时间:2023-11-03 18:53:14 25 4
gpt4 key购买 nike

我的代码不工作,它给我一个错误提示:det: arity mismatch; 预期的参数数量与给定数量不匹配 预期:4 给出:9 参数...:

这是我的代码:

(define (det3x3 a b c
d e f
g h i)
(+ (* a ( * e i (* h f)))(* b (* d i (* g f)))(* c (* d h (* e g)))))
(display "(det 0 5 -6 8 -11 4 5 1 1) = ")(det 0 5 -6
8 -11 4
5 1 1)

最佳答案

行列式 = a(ei − fh) − b(di − fg) + c(dh − eg)

(define (det3x3 a b c
d e f
g h i)
(+ (- (* a (- (* e i) (* f h)))
(* b (- (* d i) (* f g))))
(* c (- (* d h) (* e g)))))

e,g:

> (det3x3 0 5 -6
8 -11 4
5 1 1)
-318

关于Scheme Lisp 3 × 3 矩阵的行列式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54496286/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com