Error when using distributive property

조회 수: 2 (최근 30일)
D G
D G 2011년 7월 26일
Hello!
The function below compares the output of two functions which run the same calculation. However, in one function the calculation's multiplications are distributed. It should output a matrix of 1s. However, it doesn't!
What's up with that?
function errorTest()
compute(1:100) == distributed(1:100)
function out = compute(a)
out = 10.1 * (a - 1);
end
function out = distributed(a)
out = 10.1 * a - 10.1;
end
end
Thanks!

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 7월 26일
The propagation of floating approximations is different:
idx = abs(compute(1:100) - distributed(1:100)) > 2*eps
nnz(idx)
How many values over 2eps?
  댓글 수: 4
D G
D G 2011년 7월 26일
I guess I had that backwards. If you remove the 2*, a lot of the answers are still different.
Oleg Komarov
Oleg Komarov 2011년 7월 26일
Cannot really help you more than that, I don't have experience with distributed server.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by