2 * Introduction to wrstcse::
3 * Functions and Variables for wrstcse::
6 @node Introduction to wrstcse, Functions and Variables for wrstcse, Package wrstcse, Package wrstcse
7 @section Introduction to wrstcse
9 @code{wrstcse} is a naive go at interval arithmetics is powerful enough to
10 perform worst case calculations that appear in engineering by applying
11 all combinations of tolerances to all parameters.
13 This approach isn't guaranteed to find the exact combination of parameters
14 that results in the worst-case. But it avoids the problems that make a true
15 interval arithmetics affected by the halting problem as an equation can have
16 an infinite number of local minima and maxima and it might be impossible to
17 algorithmically determine which one is the global one.
19 Tolerances are applied to parameters by providing the parameter with a @var{tol[n]}
20 that wrstcase will vary between -1 and 1. Using the same @var{n} for two parameters
21 will make both parameters tolerate in the same way.
23 @code{load ("wrstcse")} loads this package.
25 @opencatbox{Categories:}
26 @category{Share packages}
27 @category{Package wrstcse}
30 @node Functions and Variables for wrstcse, , Introduction to wrstcse, Package wrstcse
31 @section Functions and Variables for wrstcse
33 @anchor{wc_typicalvalues}
34 @deffn {Function} wc_typicalvalues (@var{expression}, [@var{num}])
36 Returns what happens if all tolerances (that are represented by tol [n] that can
37 vary from 0 to 1) happen to be 0.
43 @c R_1= 1000.0*(1+tol[1]*.01),
44 @c R_2= 2000.0*(1+tol[2]*.01)
46 @c divider:U_Out=U_In*R_1/(R_1+R_2);
47 @c wc_typicalvalues(vals);
48 @c wc_typicalvalues(subst(vals,divider));
51 (%i1) load("wrstcse")$
54 R_1= 1000.0*(1+tol[1]*.01),
55 R_2= 2000.0*(1+tol[2]*.01)
57 (%o2) [R_1 = 1000.0 (0.01 tol + 1),
59 R_2 = 2000.0 (0.01 tol + 1)]
63 (%i3) divider:U_Out=U_In*R_1/(R_1+R_2);
65 (%o3) U_Out = ---------
69 (%i4) wc_typicalvalues(vals);
70 (%o4) [R_1 = 1000.0, R_2 = 2000.0]
73 (%i5) wc_typicalvalues(subst(vals,divider));
74 (%o5) U_Out = 0.3333333333333333 U_In
79 @anchor{wc_inputvalueranges}
80 @deffn {Function} wc_inputvalueranges (@var{expression}, [@var{num}])
82 Convenience function: Displays a list which parameter can vary between
89 @c R_1= 1000.0*(1+tol[1]*.01),
90 @c R_2= 2000.0*(1+tol[2]*.01)
92 @c wc_inputvalueranges(vals);
95 (%i1) load("wrstcse")$
98 R_1= 1000.0*(1+tol[1]*.01),
99 R_2= 2000.0*(1+tol[2]*.01)
101 (%o2) [R_1 = 1000.0 (0.01 tol + 1),
103 R_2 = 2000.0 (0.01 tol + 1)]
107 (%i3) wc_inputvalueranges(vals);
108 [ R_1 min = 990.0 typ = 1000.0 max = 1010.0 ]
110 [ R_2 min = 1980.0 typ = 2000.0 max = 2020.0 ]
115 @anchor{wc_systematic}
116 @deffn {Function} wc_systematic (@var{expression}, [@var{num}])
118 Systematically introduces @var{num} values per parameter into @var{expression}
119 and returns a list of the result. If no @var{num} is given, @var{num} defaults
122 See also @mrefdot{wc_montecarlo}
128 @c R_1= 1000.0*(1+tol[1]*.01),
129 @c R_2= 2000.0*(1+tol[2]*.01)
131 @c divider: U_Out=U_In*(R_1)/(R_1+R_2);
132 @c wc_systematic(subst(vals,rhs(divider)));
135 (%i1) load("wrstcse")$
138 R_1= 1000.0*(1+tol[1]*.01),
139 R_2= 2000.0*(1+tol[2]*.01)
141 (%o2) [R_1 = 1000.0 (0.01 tol + 1),
143 R_2 = 2000.0 (0.01 tol + 1)]
147 (%i3) divider: U_Out=U_In*(R_1)/(R_1+R_2);
149 (%o3) U_Out = ---------
153 (%i4) wc_systematic(subst(vals,rhs(divider)));
154 (%o4) [0.3333333333333334 U_In, 0.3311036789297659 U_In,
155 0.3289036544850498 U_In, 0.3355704697986577 U_In,
156 0.3333333333333333 U_In, 0.3311258278145696 U_In,
157 0.3377926421404682 U_In, 0.3355481727574751 U_In,
158 0.3333333333333333 U_In]
163 @anchor{wc_montecarlo}
164 @deffn {Function} wc_montecarlo (@var{expression}, @var{num})
166 Introduces @var{num} random values per parameter into
167 @var{expression} and returns a list of the result.
169 See also @mrefdot{wc_systematic}
175 @c R_1= 1000.0*(1+tol[1]*.01),
176 @c R_2= 2000.0*(1+tol[2]*.01)
178 @c divider: U_Out=U_In*(R_1)/(R_1+R_2);
179 @c wc_montecarlo(subst(vals,rhs(divider)),10);
182 (%i1) load("wrstcse")$
185 R_1= 1000.0*(1+tol[1]*.01),
186 R_2= 2000.0*(1+tol[2]*.01)
188 (%o2) [R_1 = 1000.0 (0.01 tol + 1),
190 R_2 = 2000.0 (0.01 tol + 1)]
194 (%i3) divider: U_Out=U_In*(R_1)/(R_1+R_2);
196 (%o3) U_Out = ---------
200 (%i4) wc_montecarlo(subst(vals,rhs(divider)),10);
201 (%o4) [0.3365488313167528 U_In, 0.3339089445851889 U_In,
202 0.314651402884122 U_In, 0.3447359711624277 U_In,
203 0.3294005710066001 U_In, 0.3330897542463686 U_In,
204 0.3397591863729343 U_In, 0.3227030530673181 U_In,
205 0.3385512773502185 U_In, 0.314764470912582 U_In]
210 @anchor{wc_mintypmax}
211 @deffn {Function} wc_mintypmax (@var{expr}, [@var{n}])
213 Prints the minimum, maximum and typical value of @var{expr}. If @var{n}
214 is positive, @var{n} values for each parameter will be tried systematically.
215 If @var{n} is negative, @var{-n} random values are used instead.
216 If no @var{n} is given, 3 is assumed.
223 @c R_1= 1000.0*(1+tol[1]*.01),
224 @c R_2= 1000.0*(1+tol[2]*.01)
227 @c divider:U_Out=U_In*R_1/(R_1+R_2);
228 @c lhs(divider)=wc_mintypmax(subst(vals,rhs(divider)));
231 (%i1) load("wrstcse")$
232 (%i2) ratprint:false$
235 R_1= 1000.0*(1+tol[1]*.01),
236 R_2= 1000.0*(1+tol[2]*.01)
238 (%o3) [R_1 = 1000.0 (0.01 tol + 1),
240 R_2 = 1000.0 (0.01 tol + 1)]
244 (%i4) assume(U_In>0);
248 (%i5) divider:U_Out=U_In*R_1/(R_1+R_2);
250 (%o5) U_Out = ---------
254 (%i6) lhs(divider)=wc_mintypmax(subst(vals,rhs(divider)));
255 (%o6) U_Out = [min = 0.495 U_In, typ = 0.5 U_In,
261 @anchor{wc_tolappend}
262 @deffn {Function} wc_tolappend (@var{list})
264 Appends two list of parameters with tolerances renumbering the tolerances of
265 both lists so they don't coincide.
271 @c R_1= 1000.0*(1+tol[1]*.01),
272 @c R_2= 1000.0*(1+tol[2]*.01)
275 @c R_3= 1000.0*(1+tol[1]*.01),
276 @c R_4= 1000.0*(1+tol[2]*.01)
278 @c wc_tolappend(val_a,val_b);
281 (%i1) load("wrstcse")$
284 R_1= 1000.0*(1+tol[1]*.01),
285 R_2= 1000.0*(1+tol[2]*.01)
287 (%o2) [R_1 = 1000.0 (0.01 tol + 1),
289 R_2 = 1000.0 (0.01 tol + 1)]
294 R_3= 1000.0*(1+tol[1]*.01),
295 R_4= 1000.0*(1+tol[2]*.01)
297 (%o3) [R_3 = 1000.0 (0.01 tol + 1),
299 R_4 = 1000.0 (0.01 tol + 1)]
303 (%i4) wc_tolappend(val_a,val_b);
304 (%o4) [R_1 = 1000.0 (0.01 tol + 1),
306 R_2 = 1000.0 (0.01 tol + 1), R_3 = 1000.0 (0.01 tol + 1),
308 R_4 = 1000.0 (0.01 tol + 1)]
314 @anchor{wc_mintypmax2tol}
315 @deffn {Function} wc_mintypmax2tol (@var{tolname}, @var{minval}, @var{typval}, @var{maxval})
317 Generates a parameter that uses the tolerance @var{tolname} that tolerates between the
323 @c V_F: U_Diode=wc_mintypmax2tol(tol[1],.5,.75,.82);
324 @c lhs(V_F)=wc_mintypmax(rhs(V_F));
327 (%i1) load("wrstcse")$
329 (%i2) V_F: U_Diode=wc_mintypmax2tol(tol[1],.5,.75,.82);
331 (%o2) U_Diode = (- 0.09000000000000002 tol ) + 0.16 tol + 0.75
335 (%i3) lhs(V_F)=wc_mintypmax(rhs(V_F));
336 (%o3) U_Diode = [min = 0.5, typ = 0.75, max = 0.8199999999999998]