0
$\begingroup$

I want a work program to print the values that make expr less than 0.5 when $R_n \in (0,1)$.

exp = 
  Subscript[R, 1] Subscript[R, 2] Subscript[R, 5] Subscript[R, 6] Subscript[R, 11] + 
  Subscript[R, 1] Subscript[R, 3] Subscript[R, 5] Subscript[R, 6] Subscript[R, 11] - 
  Subscript[R, 1] Subscript[R, 2] Subscript[R, 3] Subscript[R, 5] Subscript[R, 6] Subscript[R, 11] + 
  Subscript[R, 1] Subscript[R, 2] Subscript[R, 7] Subscript[R, 11]; 
variables = SortBy[Variables[exp], Last];
values = Array[Symbol["v" <> ToString[#]] &, Length @ Variables[exp]];

Manipulate[
  Evaluate[exp /. Thread[variables -> values] // Style[#, 24] &],
  Evaluate[
    ## & @@ 
      ({{#, .5, ToString[#2, TraditionalForm]}, 0, 1, Appearance -> "Labeled"}& 
        @@@ Transpose[{values, variables}])], 
  Alignment -> Center]

enter image description here

I want a program or device policewoman prints values in the equation that make expless than 0.5 and deliver in the form of a table. Such an image or in any other form while maintaining the condition

enter image description here

Make compensation per ten and percent values like....$0.nn$ when n=0,1,...,9

$\endgroup$
4
  • $\begingroup$ @kglr ...Can you help me ... With thanks and respect $\endgroup$ Commented Mar 2, 2017 at 12:48
  • 2
    $\begingroup$ if your r values are only restricted to be reals in the range 0,1 your table will be infinitely large. Do you want a bunch of random solutions or what? $\endgroup$
    – george2079
    Commented Mar 2, 2017 at 12:58
  • 1
    $\begingroup$ @george2079 ... Yes Make compensation per ten and percent values....$0.nn$ when n=0,1,...,9 $\endgroup$ Commented Mar 2, 2017 at 13:11
  • $\begingroup$ @george2079 .... I want a bunch of random solutions. $\endgroup$ Commented Mar 2, 2017 at 13:27

2 Answers 2

1
$\begingroup$
v = Variables[exp];
Prepend[N[
   Append[v, exp] /. 
    FindInstance[exp < 1/2 && 0 < # < 1 & /@ v , v , 20]], 
  Append[v, "exp"]] // MatrixForm

enter image description here

One way to restrict the results to even 10's is to round and then double check we still meet the criterea.

TableForm[
 Sort@Select[Join[#, {(exp /. Rule @@@ Transpose[{v, #}])}] & /@
    Union[
     Round[v /. 
       FindInstance[(exp /. Subscript[R, n_] :> Subscript[R, n]) < 
            1/2 &&
            0.05 < # < .95 & /@ v , v , 20], .1]] , Last[#] < .5 &], 
 TableHeadings -> {None, Join[v, {"exp"}]}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Wonderful ... Can you make compensation values in $R_n$ = $\{0,0.1,0.2,... ,0.9,1\}$ $\endgroup$ Commented Mar 2, 2017 at 14:49
  • $\begingroup$ in the second code some error like ....ReplaceAll::reps: {Transpose[v->Round[True,0.1]]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. $\endgroup$ Commented Mar 2, 2017 at 15:37
  • $\begingroup$ Treatment be slow in the first program is the second program ... and a beautiful table display my form but some Alakhto ... With thanks and respect to help me. $\endgroup$ Commented Mar 2, 2017 at 16:12
2
$\begingroup$
exp = Subscript[R, 1] Subscript[R, 2] Subscript[R, 5] Subscript[R, 
     6] Subscript[R, 11] +
   Subscript[R, 1] Subscript[R, 3] Subscript[R, 5] Subscript[R, 
     6] Subscript[R, 11] -
   Subscript[R, 1] Subscript[R, 2] Subscript[R, 3] Subscript[R, 
     5] Subscript[R, 6] Subscript[R, 11] +
   Subscript[R, 1] Subscript[R, 2] Subscript[R, 7] Subscript[R, 11];

variables = exp // Variables // Sort;

Module[{expValue, varValues},
 With[{nbrOfResults = 15},
    Table[
      Catch[
       Do[
        If[(expValue = Round[
             exp /. Thread[
               variables -> (varValues =
                  Round[RandomReal[{0, 1}, Length[variables]], .1])],
             0.01]) < 1/2,
         Throw[{
            NumberForm[#, {3, 1}] & /@ varValues,
            NumberForm[expValue, {4, 2}]} //
           Flatten]],
        10000]],
      {nbrOfResults}] //
     SortBy[#, Last] &] //
   Prepend[#, {variables, "exp"} // Flatten] & //
  Grid[#, Frame -> All] &]

enter image description here

$\endgroup$
2
  • $\begingroup$ Wonderful ...Treatment is faster here in the program ... Can you change the shape of the table ... with thanks and respect to help me. $\endgroup$ Commented Mar 2, 2017 at 16:10
  • $\begingroup$ The shape of the table is determined by the number of variables in exp and the nbrOfResults that you specify in the With statement. $\endgroup$
    – Bob Hanlon
    Commented Mar 2, 2017 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.