Jump to content

Resistor mesh: Difference between revisions

m
→‎{{header|Perl}}: dial back precision
m (→‎{{header|Perl}}: dial back precision)
Line 1,451:
{{trans|C}}
<lang perl>use strict;
use warnings;
 
my ($w, $h) = (9, 9);
Line 1,487 ⟶ 1,488:
sub iter {
my $diff = 1;
while ($diff > 1e-2415) { # 1e-24 is overkill (12 digits of precision)
set_boundary();
$diff = calc_diff();
#print "error^2: $diff\rn"; # un-comment to see slow convergence
for my $i (0 .. $h) {
for my $j (0 .. $w) {
Line 1,497 ⟶ 1,498:
}
}
print "\n";
 
my @current = (0) x 3;
Line 1,509:
}
 
printprintf "R = @{[%.6f", 2 / iter()]}\n";</lang>
 
=={{header|Perl 6}}==
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.