Das Skript ist per Menü (s.u.) gesteuert.
Es errechnet den Gesamtwert von parallel geschalteten Widerständen.
Das Skript soll Angebote zu einem gewünschten Zielwert machen.

Die nachfolgende Skript-Version ist etwa 2,5-fach schneller als die am Ende
und verwendet die neueste bsh V6.22 (typeset).

#!/u/bin/bsh

set -f
ARITH_FMT='%.9Lg'
# r= (10^(1/24))^n ; n=0..23..
 E6='1.0 1.5 2.2 3.3 4.7 6.8'
E12='1.0 1.2 1.5 1.8 2.2 2.7 3.3 3.9 4.7 5.6 6.8 8.2'
E24='1.0 1.1 1.2 1.3 1.5 1.6 1.8 2.0 2.2 2.4 2.7 3.0
     3.3 3.6 3.9 4.3 4.7 5.1 5.6 6.2 6.8 7.5 8.2 9.1'
E48='1.00 1.05 1.10 1.15 1.21 1.27 1.33 1.40 1.47 1.54 1.62 1.69
     1.78 1.87 1.96 2.05 2.15 2.26 2.37 2.49 2.61 2.74 2.87 3.01
     3.16 3.32 3.48 3.65 3.83 4.02 4.22 4.42 4.64 4.87 5.11 5.36
     5.62 5.90 6.19 6.49 6.81 7.15 7.50 7.87 8.25 8.66 9.09 9.53'
E96='1.00 1.02 1.05 1.07 1.10 1.13 1.15 1.18 1.21 1.24 1.27 1.30
     1.33 1.37 1.40 1.43 1.47 1.50 1.54 1.58 1.62 1.65 1.69 1.74
     1.78 1.82 1.87 1.91 1.96 2.00 2.05 2.10 2.15 2.21 2.26 2.32
     2.37 2.43 2.49 2.55 2.61 2.67 2.74 2.80 2.87 2.94 3.01 3.09
     3.16 3.24 3.32 3.40 3.48 3.57 3.65 3.74 3.83 3.92 4.02 4.12
     4.22 4.32 4.42 4.53 4.64 4.75 4.87 4.99 5.11 5.23 5.36 5.49
     5.62 5.76 5.90 6.04 6.19 6.34 6.49 6.65 6.81 6.98 7.15 7.32
     7.50 7.68 7.87 8.06 8.25 8.45 8.66 8.87 9.09 9.31 9.53 9.76'
E=24 Tol=0.3 Zeilen=12
Beg=10.0 End=1e6
Del='1e6
'


Err()  { print -u2 "$1"; exit 1; }

k='${#E'"$E"'}'
eval k=$k
[ -z "$k" -o k -lt 11 ] && Err "Falsche E-Reihe: E$E"


FillBuf()  {
   local er=... r=.... r0=0000 f=0 lg:025 sf:025
   local c:08 o:08 n:08 fak:025
   local sz=$(typeset -F)
   typeset -f a zero
   let "Beg<1.0" && Err "Startwert<1: $Beg"
   let "Beg>=End" && Err "Startwert>=Endwert: $Beg $End"
   [ E -eq $1 ] && return 0
   [ $1 -gt 0 ] && E=$1
   er=E$E  : ${{er}} ; n=$,
   [ n -ne E ] && Err "Falsche Anzahl Werte $er: $n"
   let "fak=pow(10.0,1.0/E), r0=1.0/fak"
   for r in ${{er}}
   do
      let "r<1.0" && Err "$er-Wert < 1: $r"
      let "r>a" || Err "$er-Wert nicht streng monoton steigend: $r"
      let "r/r0>fak*1.05||r/r0<fak/1.05" &&
          Err "$er-Wert-Faktor vom Vorwert her unpassend: $r/$r0"
      a=$r r0=$r
      [ f -eq 1 ] && continue
      let "lg=log10(End/r)" "lg-trunc(lg)>0.0" && continue
      f=1
   done
   [ f -ne 1 ] && Err "Endwert unpassend: $End"
   f=0
   for r in ${{er}}
   do
      let "r<1.0" && Err "$er-Wert < 1: $r"
      [ f -eq 1 ] && continue
      let "lg=log10(Beg/r)" "lg-trunc(lg)>0.0" && continue
      let "sf=Beg/r"
      f=1 echo Startwert-Faktor: $sf
   done
   [ f -ne 1 ] && Err "Startwert unpassend: $Beg"
   set BUF:32.$(( llround(ceil(log10(End/Beg))*E*sz+E*sz) ))
   n=${#BUF}
   echo "Puffergroesse: $n"
   echo "Puffergroesse: $((n/sz)) Einträge"
   f=0 o=0
   while :
   do
      for r in ${{er}}
      do
         let "a=sf*r"
         if [ f -eq 1 ]
         then  catv a =o,sz,BUF
         else  let "a!=Beg" && continue
               f=1 catv a =o,sz,BUF
         fi
         let "o+=sz" "a==End" || continue
         let "n=o/sz"
         break 2
      done
      let "sf*=10"
   done
   N=$n
   echo "Einträge: $n"
   Del=$Del
   [ -z "$Del" ] && return 0
   c=0
   for o from 0 by $sz to $((n*sz-sz)) repeat
   do
      catv o,sz,BUF =a
      for r in $Del
      do
         let "a!=r" && continue
         catv zero =o,sz,BUF
         let "++c"
      done
   done
   echo "Pufferwerte gelöscht: $c"
   set BUFC:32.${#BUF}
   catv BUF =BUFC
   c=0
   for o from 0 by $sz to $((n*sz-sz)) repeat
   do
      catv o,sz,BUFC =a
      let "a<1.0" && continue
      catv a =c,sz,BUF ; let "c+=sz"
   done
   let "N=c/sz"
   echo "Einträge: $N"
   return 0
}

FillBuf -1

GetRpar()  {
   local o:08 oa:08 ob:08 oc:08 m:025 t:08 f=0
   local sz=$(typeset -F)
   typeset -f a b c v zp zm ziel=$1
   let "t=N*sz-sz"
   let "zp=ziel*(1.0+Tol/100.0)" "zm=ziel*(1.0-Tol/100.0)"
   for o from 0 by $sz to $t repeat
   do
      catv o,sz,BUF =v
      let "v>=ziel" && { f=1; break; }
   done
   [ f -ne 1 ] && return 1
   for oa from $o by $sz to $t repeat
   do
      catv oa,sz,BUF =v
      if let "v<=zp&&v>=zm"
      then
         let "m=fabs(v/ziel-1.0), m=llround(m*1e6)"
         echo "%t1 $m # $ziel : $v = $v"
      fi
   done
   for oa from $o by $sz to $t repeat
   do
      catv oa,sz,BUF =a
      for ob from $o by $sz to $t repeat
      do
         catv ob,sz,BUF =b
         let "a==ziel||b==ziel" && break 2
         let "a>b" && continue
         let "v=rpar2(a,b)"
         if let "v<=zp&&v>=zm"
         then
            let "m=fabs(v/ziel-1.0), m=llround(m*1e6)"
            echo "%t2 $m # $ziel : $v = $a|$b"
         fi
      done
   done
   for oa from $o by $sz to $t repeat
   do
      catv oa,sz,BUF =a
      for ob from $o by $sz to $t repeat
      do
         catv ob,sz,BUF =b
         let "a>b" && continue
         for oc from $o by $sz to $t repeat
         do
            catv oc,sz,BUF =c
            let "a==ziel||b==ziel||c==ziel" && break 3
            let "a>c||b>c" && continue
            let "v=rpar3(a,b,c)"
            if let "v<=zp&&v>=zm"
            then
               let "m=fabs(v/ziel-1.0), m=llround(m*1e6)"
               echo "%t3 $m # $ziel : $v = $a|$b|$c"
            fi
         done
      done
   done
   return 0
}


Results()  {
   local zln=$Zeilen ap0=0 ap=0
   local ppm:010 ziel:025 val:025 pr:.40
   GetRpar "$1" | sortl -fn1,n2 | {
      while read ap ppm - ziel - val - pr
      do
         [ ap -ne ap0 ] && { ap0=$ap zln=$Zeilen; echo; }
         [ zln -eq 0 ] && continue
         expr "$pr" :pr '%.0%([^0-9]%)' + '%1'
         expr "$pr" :pr '%.0$' = ''
         expr "$pr" :pr '|' += ' | '
         prints s12bsbs9bsbs-12bsbs $ppm : $ziel : $val = "$pr"
         let "--zln"
      done
   }
   return 0
}


local z=000 e=000 t=000000
prints vs-2 z $Zeilen
prints vs-2 e $E
prints vs-4 t $Tol

while echo "
%tStartwert=$Beg  Endwert=$End
%tReihe=E$e    : e#    (e6 e12 e24 e48 e96)
%tZeilen=$z    : z #
%tToleranz=$t: t #
%tZielwert     : zahl  (123 12.3 12e3 ...)
%tBeenden      : E
%t             : _%b%c"
do
   read cmd arg
   case "$cmd" in
      e6)  FillBuf  6;;
     e12)  FillBuf 12;;
     e24)  FillBuf 24;;
     e48)  FillBuf 48;;
     e96)  FillBuf 96;;
       z)  expr "$arg" :: '[1-9][0-9]*' || { echo '%a%c'; continue; }
           Zeilen=$arg;;
       t)  expr "$arg" :: '[0-9][0-9.]*' || { echo '%a%c'; continue; }
           Tol=$arg;;
     [0-9]*)  Results "$cmd";;
       E)  break;;
       *)  echo '%a%c'; continue;;
   esac
   prints vs-2 z $Zeilen
   prints vs-2 e $E
   prints vs-4 t $Tol
done

:


#!/u/bin/bsh

set -f
ARITH_FMT='%.9Lg'
# r= (10^(1/24))^n ; n=0..23..
 E6='1.0 1.5 2.2 3.3 4.7 6.8'
E12='1.0 1.2 1.5 1.8 2.2 2.7 3.3 3.9 4.7 5.6 6.8 8.2'
E24='1.0 1.1 1.2 1.3 1.5 1.6 1.8 2.0 2.2 2.4 2.7 3.0
     3.3 3.6 3.9 4.3 4.7 5.1 5.6 6.2 6.8 7.5 8.2 9.1'
E48='1.00 1.05 1.10 1.15 1.21 1.27 1.33 1.40 1.47 1.54 1.62 1.69
     1.78 1.87 1.96 2.05 2.15 2.26 2.37 2.49 2.61 2.74 2.87 3.01
     3.16 3.32 3.48 3.65 3.83 4.02 4.22 4.42 4.64 4.87 5.11 5.36
     5.62 5.90 6.19 6.49 6.81 7.15 7.50 7.87 8.25 8.66 9.09 9.53'
E=24 Tol=0.3 Zeilen=12
Beg=10.0 End=1e6
Del='1e6
'


Err()  { print -u2 "$1"; exit 1; }

e='${#E'"$E"'}'
eval e=$e
[ -z "$e" -o e -lt 11 ] && Err "Falsche E-Reihe: E$E"


FillBuf()  {
   local er=... r=.... r0=0000 f=0 lg:025 sf:025 a:025
   local lz:32.20 c:08 o:08 n:08 fak:025
   let "Beg<1.0" && Err "Startwert<1: $Beg"
   let "Beg>=End" && Err "Startwert>=Endwert: $Beg $End"
   [ E -eq $1 ] && return 0
   [ $1 -gt 0 ] && E=$1
   er=E$E  : ${{er}} ; a=$,
   [ a -ne E ] && Err "Falsche Anzahl Werte $er: $a"
   a=0.0 let "fak=pow(10.0,1.0/E), r0=1.0/fak"
   for r in ${{er}}
   do
      let "r<1.0" && Err "$er-Wert < 1: $r"
      let "r>a" || Err "$er-Wert nicht streng monoton steigend: $r"
      let "r/r0>fak*1.05||r/r0<fak/1.05" &&
          Err "$er-Wert-Faktor vom Vorwert her unpassend: $r/$r0"
      a=$r r0=$r
      [ f -eq 1 ] && continue
      let "lg=log10(End/r)" "lg-trunc(lg)>0.0" && continue
      f=1
   done
   [ f -ne 1 ] && Err "Endwert unpassend: $End"
   f=0
   for r in ${{er}}
   do
      let "r<1.0" && Err "$er-Wert < 1: $r"
      [ f -eq 1 ] && continue
      let "lg=log10(Beg/r)" "lg-trunc(lg)>0.0" && continue
      let "sf=Beg/r"
      f=1 echo Startwert-Faktor: $sf
   done
   [ f -ne 1 ] && Err "Startwert unpassend: $Beg"
   set BUF:32.$(( llround(ceil(log10(End/Beg))*E*20+E*20) ))
   a=${#BUF}
   echo "Puffergroesse: $a"
   echo "Puffergroesse: $((a/20)) Einträge"
   f=0 o=0
   while :
   do
      for r in ${{er}}
      do
         let "a=sf*r"
         if [ f -eq 1 ]
         then  catv a =o,20,BUF
         else  let "a!=Beg" && continue
               f=1 catv a =o,20,BUF
         fi
         let "o+=20" "a==End" || continue
         let "n=o/20"
         break 2
      done
      let "sf*=10"
   done
   N=$n
   echo "Einträge: $n"
   Del=$Del
   [ -z "$Del" ] && return 0
   c=0
   for o from 0 by 20 to $((n*20-20)) repeat
   do
      catv o,20,BUF =a:
      a=$a
      for r in $Del
      do
         let "a!=r" && continue
         catv lz =o,20,BUF
         let "++c"
      done
   done
   echo "Pufferwerte gelöscht: $c"
   set BUFC:32.${#BUF}
   catv BUF =BUFC
   c=0
   for o from 0 by 20 to $((n*20-20)) repeat
   do
      catv o,20,BUFC =a:
      catv 1,a =f:
      [ "$f" = ' ' ] && continue
      catv a =c,20,BUF ; let "c+=20"
   done
   let "N=c/20"
   echo "Einträge: $N"
   return 0
}

FillBuf -1

GetRpar()  {
   local o:08 oa:08 ob:08 oc:08 a:025 b:025 c:025
   local ziel=$1 v:025 m:025 zp:025 zm:025 t:08 f=0
   let "t=N*20-20"
   let "zp=ziel*(1.0+Tol/100.0)" "zm=ziel*(1.0-Tol/100.0)"
   for o from 0 by 20 to $t repeat
   do
      catv o,20,BUF =v: ; v=$v
      let "v>=ziel" && { f=1; break; }
   done
   [ f -ne 1 ] && return 1
   for oa from $o by 20 to $t repeat
   do
      catv oa,20,BUF =a: ; v=$a
      if let "v<=zp&&v>=zm"
      then
         let "m=fabs(v/ziel-1.0), m=llround(m*1e6)"
         echo "%t1 $m # $ziel : $v = $v"
      fi
   done
   for oa from $o by 20 to $t repeat
   do
      catv oa,20,BUF =a: ; a=$a
      for ob from $o by 20 to $t repeat
      do
         catv ob,20,BUF =b: ; b=$b
         let "a==ziel||b==ziel" && break 2
         let "a>b" && continue
         let "v=rpar2(a,b)"
         if let "v<=zp&&v>=zm"
         then
            let "m=fabs(v/ziel-1.0), m=llround(m*1e6)"
            echo "%t2 $m # $ziel : $v = $a|$b"
         fi
      done
   done
   for oa from $o by 20 to $t repeat
   do
      catv oa,20,BUF =a: ; a=$a
      for ob from $o by 20 to $t repeat
      do
         catv ob,20,BUF =b: ; b=$b
         let "a>b" && continue
         for oc from $o by 20 to $t repeat
         do
            catv oc,20,BUF =c: ; c=$c
            let "a==ziel||b==ziel||c==ziel" && break 3
            let "a>c||b>c" && continue
            let "v=rpar3(a,b,c)"
            if let "v<=zp&&v>=zm"
            then
               let "m=fabs(v/ziel-1.0), m=llround(m*1e6)"
               echo "%t3 $m # $ziel : $v = $a|$b|$c"
            fi
         done
      done
   done
   return 0
}


Results()  {
   local zln=$Zeilen ap0=0 ap=0
   local ppm:010 ziel:025 val:025 pr:.40
   GetRpar "$1" | sortl -fn1,n2 | {
      while read ap ppm - ziel - val - pr
      do
         [ ap -ne ap0 ] && { ap0=$ap zln=$Zeilen; echo; }
         [ zln -eq 0 ] && continue
         expr "$pr" :pr '%.0%([^0-9]%)' + '%1'
         expr "$pr" :pr '%.0$' = ''
         expr "$pr" :pr '|' += ' | '
         prints s12bsbs9bsbs-12bsbs $ppm : $ziel : $val = "$pr"
         let "--zln"
      done
   }
   return 0
}



while echo "
%tStartwert=$Beg  Endwert=$End
%tReihe=E$E  Zielwert-Toleranz=$Tol%%
%tWahl E6   : e6
%tWahl E12  : e12
%tWahl E24  : e24
%tWahl E48  : e48
%tZeilen max: z #   [$Zeilen]
%tToleranz  : t #   (t 0.5)
%tZielwert  : zahl  (123 12.3 12e3 ...)
%tBeenden   : E
%t          : _%b%c"
do
   read cmd arg
   case "$cmd" in
      e6)  FillBuf  6;;
     e12)  FillBuf 12;;
     e24)  FillBuf 24;;
     e48)  FillBuf 48;;
       z)  expr "$arg" :: '[1-9][0-9]*' || { echo '%a%c'; continue; }
           Zeilen=$arg;;
       t)  expr "$arg" :: '[0-9][0-9.]*' || { echo '%a%c'; continue; }
           Tol=$arg;;
     [0-9]*)  Results "$cmd";;
       E)  break;;
       *)  echo '%a%c'; continue;;
   esac
done

: