Suppose an output of Reduce[]
function looks like this:
x2 > 0 && ((0 < x1 < x2 && y2 > 0 && 0 < y1 < y2 && z1 > 0 && z2 > z1 && t1 > c1 && 0 < t2 < c2) || (x1 > x2 && y2 > 0 && y1 > y2 && z1 > 0 && z2 > z1 && t1 > 0 && t2 > c2))
I.e., Boolean formulae with inequalities of two types:
1) $x>a$, to which we associate $\left(\frac{1}{x-a}\right)$,
2) $a<x<b$, to which we associate $\left(\frac{1}{x-a}-\frac{1}{x-b}\right)$.
I would like to automatically create from the above output the following formula, which preserves all Boolean logic and for which &&
means multiplied by
and ||
means add the corresponding piece
:
$\frac{1}{x_2}\Big(\big((\frac{1}{x_1}-\frac{1}{x_1-x_2})\frac{1}{y_2}(\frac{1}{y_1}-\frac{1}{y_1-y_2})\frac{1}{z_1}\frac{1}{z_2-z_1}\frac{1}{t_1-c_1}(\frac{1}{t_2}-\frac{1}{t_2-c_2})+\frac{1}{x_1-x_2}\frac{1}{y_2}\frac{1}{y_1-y_2}\frac{1}{z_1}\frac{1}{z_2-z_1}\frac{1}{t_1}\frac{1}{t_2-c_2}\big)\Big)$
Is there an easy way to do it, given that the number of parameters $x,y,z,t,\dots$, as well as the number of nested parentheses and boolean symbols
( smthng && ( smthng || smthng ) && ( smthng && smthng && smthng )))
can be anything?
UPDATE: Also, sometimes the output contains an equality like this one:
x2==x1-a
buried somewhere inside of the parentheses:
x2 > 0 && ((x2==x1-a || 0 < x1 < x2 && y2 > 0 && 0 < y1 < y2 && z1 > 0 && z2 > z1 && t1 > c1 && 0 < t2 < c2) || (x1 > x2 && y2 > 0 && y1 > y2 && z1 > 0 && z2 > z1 && t1 > 0 && t2 > c2))
which I would like to completely ignore and not to include in the final formula. What replacement rule should I use then?