Message Boards Message Boards

0
|
3806 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Convert if function to logical expression?

Posted 3 years ago

The following logical equation defines the output of a cascaded set of six 2:1 multiplexers:

Y[n] = If[If[Y(n-2),If[Y(n-3),A(n-1),B(n-1)],If[Y(n-3),C(n-1),D(n-1)]],If[Y(n-2),A(n),B(n)],If[Y(n-2),C(n),D(n)]]

it is relatively easy to write Y(n) as a logical function of the several inputs Y(), A(), B(), C() and D(), using "and", "or" and "not" gates.

Is there a mechanism in Mathematica to convert the Ifs into an equivalent logical expression? Thanks

POSTED BY: Dr Fog
2 Replies
Posted 3 years ago

Vielen Dank Henrik for the tip and coding style suggestions, that was indeed the function I wanted:

Y1[n] = BooleanConvert[ If[If[Y[n - 2], If[Y[n - 3], a[n - 1], b[n - 1]], If[Y[n - 3], c[n - 1], d[n - 1]]], If[Y[n - 2], a[n], b[n]],  If[Y[n - 2], c[n], d[n]]]] // TraditionalFormBooleanMinimize[Y21[n], "DNF"] // TraditionalForm
BooleanMinimize[Y1[n], "DNF"] // TraditionalFor

Collect[Y1[n], {Y[n - 1], ! Y[n - 1]}, Simplify] // TraditionalForm

Not yet in the simple sum of products I expected, but it is getting there.

POSTED BY: Dr Fog

You probably want BooleanConvert. But first you need to correct your respective expression:

  • function arguments should be enclosed within [...]
  • do not begin own variable names using capitel letters!
  • the documentation is excellent - use it!
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract