## Expression simplification

I have this term

Sqrt[(B Bc)/(A^2-B Bc)]Sqrt[B Bc+A(-A+Sqrt[A^2-B Bc])]Sqrt[-B Bc+A(A + Sqrt[A^2-B Bc])], 

which actually can be simplified to B*Bc. However, it seems Mathematica cannot simplify it. Any suggestions on how I’d be able to do that? Thanks.

## Substitution of expressions in a symbolic expression

I define tables of symbolic variables in the following form (for convenience)

X = Table[Symbol["x" <> ToString[i]], {i, 1, num}]; Y = Table[Symbol["y" <> ToString[j]], {j, 1, num}];  

And after that, in cycles, I create some expressions. For example, here is one of them

Expon := Exp[ - ((X[[1]] * Y[[1]]) / 4) ];  For[i = 2, i <= num, i++,  Expon = Expon * Exp[ - ((X[[i]] * Y[[i]]) / 4)] ]  

After that, I want to act by some differential operator on my symbolic expression (let’s call it $$\Psi$$) and substitute in the final expression some tables of numbers X1 and Y1 (here they are not symbolic, but filled by real numbers). I tried to use ReplaceAll ./ command, but it didn’t work. Could you tell me please, how can I substitute two or more tables of real numbers in symbolic expression? Long story short, how to calculate something like $$\Psi(X1, Y1)$$?

## Maximize an expression with respect to a variable and minimize it with respect to other variables

I started to use Mathematica a few time ago. I want to minimize the following expression (function of $$l,p,q,r,c$$) with respect to variables $$l, p, q, r$$ and then maximize the result obtained with respect to variable $$c$$. However, when I try to obtain an expression function of $$c$$ to maximize later using Minimize, I do not get any result because it takes too long. How can I solve this issue?

Minimize[{(((l^2/2)*(1-(1/4-c))+(l*p)*(1-1/4)+(l*q)*(1-(1/4+c))+(l*r)*(1-1/2)+(p^2/2)*(1-c)+(p*q)*(1-2*c)+(p*r)*(1-(1/4+c))+(q^2/2)*(1-c)+(q*r)*(1-1/4)+(r^2/2)*(1-(1/4-c)))/((l^2/2)*(1-(1/4-c))+(l*p)*(1-1/4)+(l*q)*(1-(1/4-c))+(l*r)*(1-0)+(p^2/2)*(1-c)+(p*q)*(1-(1/4-c))+(p*r)*(1-0)+(q^2/2)*(1-(1/4-c))+(q*r)*(1-1/4)+(r^2/2)*(1-0))), l >= 1, p >= 0, q >= 0, r >= 0, l + p + q + r == 1000000, 1/7<c<1/5}, {l, p, q, r}] 

## Test two LTL expression trees for equivalence

Is there an algorithm on how to check if two LTL expressions (represented as binary trees) are semantically equivalent? Since there are many smaller equivalences such as $$a\Rightarrow b \equiv \neg a \vee b$$ or $$F(a) \equiv true U a$$ as well as commutativity, distributivity, etc. that need to be considered.
My initial idea was to create the truth table for both expressions and compare them. But then the temporal operators would not be taken into account. Creating and comparing the automaton for each expression sounds like it would be rather inefficient.

Is there a better way to do this?

## How to apply Arden’s theory to determine a regular expression

If P=(ab) and Q=(a)* How do I use Arden’s theorem to determine the regular expression R. I’m not sure if I am supposed to just substitute the values of P and Q in the equation R= Q + RP. Also how would I use that to check that R satisfies Arden’s equation

## Problem using ‘Regular expression’ in order to split characters of a column when there is no delimiter between them

I have a table with below structure:

create table TBL_TEST (   col_id   NUMBER,   col_name VARCHAR2(500) ) 

Some example data :

col_id | col_name    -----------------   1    | aetnap           2    | elppa          3    | ananab        

What I need to do is to split characters of column col_name for each col_id for example for col_id=1 we must have :

col_id | col_name    -----------------   1    | a   1    | e   1    | t   1    | n   1    | a   1    | p 

this query is fine when there is only one record in the table :

SELECT col_id, REGEXP_SUBSTR(col_name, '[a-z]{1}', 1, LEVEL) AS VAL   FROM tbl_test t CONNECT BY REGEXP_SUBSTR(col_name, '[a-z]{1}', 1, LEVEL) is not null 

but as soon as I insert another record in the table (say col_id=2 and col_id=3) I can not have the desired result. I want to know two things:

1. Why is this query works fine for one record and it does not for more ?
2. what is the best way to split the characters when there is no delimiter between them?

## How to write “∀x.F(x)” for “F(x)=λx.Φ(x)” in one expression (sequel from question about “∀(λφ. (φ x m→ φ y))”?

This question is sequel from How to understand quantifier without predication " ∀(λφ. (φ x m→ φ y))"? which further explains the notation and context.

So – I have anonymous Boolean-valued function F(y)=λx.Φ(x) (of course, y and x point to the same variable, I just used different syntactic names, to point out, that x is bound variable) and I would like to write the statement, that F(x) is true for all the values of the argument and it can be written ∀x.F(x). But F(x) is named function, but I would like to write the same expression for the anonymous function that uses lambda, so I am with my suggestion: ∀x.λx.Φ(x) or ∀x.λy.Φ(y)? And apparently they both are wrong.

What I am trying to achieve? I just want to build parser for language that is declared in https://www.isa-afp.org/browser_info/current/AFP/GoedelGod/GoedelGod.html. This language contains expressions like [∀(λΦ. P (λx. m¬ (Φ x)) m→ m¬ (P Φ))].

I am using ANTLR grammar for lambda calculus https://github.com/antlr/grammars-v4/blob/master/lambda/lambda.g4 and I understand that the 1) quantifiers; 2) logical connectives; 3) arithmetic functions are just another lambda functions (it is just syntactic sugar that they are written in the specific non-lambda syntax/prefix form etc.) and as such I express them in the existing lambda.g4 grammar https://github.com/antlr/grammars-v4/blob/master/lambda/lambda.g4. So – my first step is to write the cited expressions with the named functions and then I will just replace them with anonymous functions because lambda.g4 has no options to introduce named functions. But it is so confusing to write anonymous function and the quantifier function for the same argument.

Just side question – maybe there is better ANTLR grammar for lambda calculus with syntactic sugar for quantifiers and connectives?

## Time computation problems with “Maximize” expression

I just started to use Mathematica a few weeks ago. I am afraid there is something that does not work on my laptop because, for the following simple command, it takes too much time. Do you know if there is a mistake in this command syntax? Thank you in advance for your help.

Maximize[{(g/e)*Sqrt[((g – e)^2 + (f – h)^2)], 0 <= e <= 1, 0 <= f <= 1, e^2 + f^2 == 1, 0 <= g <= e, 0 <= h <= f}, {e, f, g, h}]

## Is there a function to convert a trigonmetric expression to an algebraic expression suitable for ComplexPlot?

According to H. A Priesley:

"both $$cosθ$$ and $$sinθ$$ can be written as simple algebraic functions of $$z$$":

$$cosθ =\frac{1}{2} (z + \frac{1}{z}) \tag1$$ $$sinθ =\frac{1}{2i} (z − \frac{1}{z})\tag2$$

Which is very handy but I’m not sure what function will convert say $$\frac{\sinh(ax)}{\sinh(bx)}\,$$ ot $$\frac{x\cos ax}{1+x^2}\coth \frac{\pi x}{4}$$ to similar algebraic functions. The only function I can find is TrigtoExp, but this does not include the needed substution $$z = \exp iθ$$ to work with function ComplexPlot.

Q1. Is there a function to convert a trigonmetric expression to an algebraic expression suitable for ComplexPlot?

Q2. If not what is the best way to get around this?

## Problem plotting expression involving Generalized hypergeometric functions $_2F_2 \left(.,.,. \right)$

I’m trying to plot a graph for the following expectation

$$\mathbb{E}\left[ a \mathcal{Q} \left( \sqrt{b } \gamma \right) \right]=a 2^{-\frac{\kappa }{2}-1} b^{-\frac{\kappa }{2}} \theta ^{-\kappa } \left(\frac{\, _2F_2\left(\frac{\kappa }{2}+\frac{1}{2},\frac{\kappa }{2};\frac{1}{2},\frac{\kappa }{2}+1;\frac{1}{2 b \theta ^2}\right)}{\Gamma \left(\frac{\kappa }{2}+1\right)}-\frac{\kappa \, _2F_2\left(\frac{\kappa }{2}+\frac{1}{2},\frac{\kappa }{2}+1;\frac{3}{2},\frac{\kappa }{2}+\frac{3}{2};\frac{1}{2 b \theta ^2}\right)}{\sqrt{2} \sqrt{b} \theta \Gamma \left(\frac{\kappa +3}{2}\right)}\right)$$ where $$a$$ and $$b$$ are constant values, $$\mathcal{Q}$$ is the Gaussian Q-function, which is defined as $$\mathcal{Q}(x) = \frac{1}{\sqrt{2 \pi}}\int_{x}^{\infty} e^{-u^2/2}du$$ and $$\gamma$$ is a random variable with Gamma distribition, i.e., $$f_{\gamma}(y) \sim \frac{1}{\Gamma(\kappa)\theta^{\kappa}} y^{\kappa-1} e^{-y/\theta}$$ with $$\kappa > 0$$ and $$\theta > 0$$.

This equation was also found with Mathematica, so it seems to be correct. I’ve got the same plotting issue with Matlab.

Follows some examples, where I have checked the analytical results against the simulated ones.

When $$\kappa = 12.85$$, $$\theta = 0.533397$$, $$a=3$$ and $$b = 1/5$$ it returns the correct value $$0.0218116$$.

When $$\kappa = 12.85$$, $$\theta = 0.475391$$, $$a=3$$ and $$b = 1/5$$ it returns the correct value $$0.0408816$$.

When $$\kappa = 12.85$$, $$\theta = 0.423692$$, $$a=3$$ and $$b = 1/5$$ it returns the value $$-1.49831$$, which is negative. However, the correct result should be a value around $$0.0585$$.

When $$\kappa = 12.85$$, $$\theta = 0.336551$$, $$a=3$$ and $$b = 1/5$$ it returns the value $$630902$$. However, the correct result should be a value around $$0.1277$$.

Therefore, the issue happens as $$\theta$$ decreases. For values of $$\theta > 0.423692$$ the analytical matches the simulated results. The issue only happens when $$\theta <= 0.423692$$.

I’d like to know if that is an accuracy issue or if I’m missing something here and if there is a way to correctly plot a graph that matches the simulation. Perhaps there is another way to derive the above equation with other functions or there might be a way to simplify it and get more accurate results.