More documentation and comment out debugging print.
[maxima.git] / share / contrib / wrstcse.dem
blob78b60df813219bc04d09bc9ea347cbe77d9ed04b
1 load("wrstcse")$ratprint:false$
2 load("engineering-format")$
3 engineering_format_min: .01$engineering_format_max: 1100$fpprintprec: 6$
5 printf(false,"The output voltage of a voltage divider");
6 div1:I=U_In/(R_1+R_2);
7 div2:U_Out=I*R_2;
8 div:subst(div1,div2);
10 printf(false,"Every store keeps 1% resistors or better.");
12 vals_discrete:[
13     R_1=10e3*(1+.01*tol[1]),    
14     R_2=1e3* (1+.01*tol[2])
16 wc_inputvalueranges(vals_discrete);
18 assume(U_In>0);
19 wc_typicalvalues(subst(vals_discrete,div));
20 lhs(div)=wc_mintypmax(subst(vals_discrete,rhs(div)));
21 printf(false,"Trying more values per resistor to verify this result:");
22 lhs(div)=wc_mintypmax(subst(vals_discrete,rhs(div)),40);
23 printf(false,"Trying 100 random values per resistor to verify this result:");
24 lhs(div)=wc_mintypmax(subst(vals_discrete,rhs(div)),-100);
26 printf(false,"Inside a semiconductor tolerances are big but tightly coupled:");
27 vals_ic:[
28     R_1=10e3*(1+.2*tol[1]+.0001*tol[2]),    
29     R_2=1e3* (1+.2*tol[1]+.0001*tol[3])
31 wc_inputvalueranges(vals_ic);
32 lhs(div)=wc_mintypmax(subst(vals_ic,rhs(div)));
34 printf(false,"An asymmetric tolerance range:");
36 vals_t:[
37     R_1=10e3*(1+.01*tol[1]),    
38     U_BE=wc_mintypmax2tol(tol[2],.6,.75,.85)
40 wc_inputvalueranges(%);
41 ib:I_B=(U_In-U_BE)/R_1;
43 lhs(ib)=wc_mintypmax(subst(vals_t,rhs(ib)));
44 printf(false,"This result is correct. An additional assumption makes it simpler:");
45 assume(U_In>10);
46 lhs(ib)=wc_mintypmax(subst(vals_t,rhs(ib)));
47 wc_systematic(subst(vals_t,rhs(ib)));
48 apply('min,%);