Simplifying this complicated Mathematica result using known definitions - wolfram-mathematica

While solving a boundary value problem, I reached the following expression for a Fourier constant (CC01) after simplification using Simplify. The expression is still huge. Is there any way to simplify this further in Mathematica using some definitions I mention below (or without using them)
CC01 = (32 E^(
w γ) (-E^(-w γ)
pc (Ta - tci) δ (NTUC^2 + δ^2) Sin[α/
2] Sin[α/2 + β] (-2 E^NTUH NTUH^3 ph α +
2 E^NTUH NTUH ph α^3 -
2 E^NTUH NTUH^2 ph α^3 - 2 E^NTUH ph α^5 +
2 E^NTUH NTUH^4 α γ +
4 E^NTUH NTUH^2 α^3 γ +
2 E^NTUH α^5 γ +
2 NTUH ph α (NTUH^2 - α^2) Cos[α] +
E^NTUH NTUH ph α (NTUH^2 + α^2) Cos[
2 β] +
E^NTUH NTUH^3 ph α Cos[2 (α + β)] +
E^NTUH NTUH ph α^3 Cos[2 (α + β)] -
2 NTUH^3 ph α Cos[α + 2 β] -
2 NTUH ph α^3 Cos[α + 2 β] -
4 NTUH^2 ph α^2 Sin[α] -
E^NTUH NTUH^2 ph α^2 Sin[2 β] -
E^NTUH ph α^4 Sin[2 β] +
E^NTUH NTUH^4 γ Sin[2 β] +
2 E^NTUH NTUH^2 α^2 γ Sin[2 β] +
E^NTUH α^4 γ Sin[2 β] +
E^NTUH NTUH^2 ph α^2 Sin[2 (α + β)] +
E^NTUH ph α^4 Sin[2 (α + β)] -
E^NTUH NTUH^4 γ Sin[2 (α + β)] -
2 E^NTUH NTUH^2 α^2 γ Sin[
2 (α + β)] -
E^NTUH α^4 γ Sin[2 (α + β)]) (E^
NTUC δ Cos[θ] - δ Cos[δ + \
θ] + E^NTUC NTUC Sin[θ] -
NTUC Sin[δ + θ]) (2 δ +
Sin[2 θ] - Sin[2 (δ + θ)]) -
ph (Ta -
thi) α (NTUH^2 + α^2) (E^
NTUH α Cos[β] - α Cos[α + \
β] + E^NTUH NTUH Sin[β] -
NTUH Sin[α + β]) (2 α + Sin[2 β] -
Sin[2 (α + β)]) Sin[δ/
2] Sin[δ/2 + θ] (2 E^NTUC NTUC^3 pc δ +
2 E^NTUC NTUC^4 γ δ -
2 E^NTUC NTUC pc δ^3 +
2 E^NTUC NTUC^2 pc δ^3 +
4 E^NTUC NTUC^2 γ δ^3 +
2 E^NTUC pc δ^5 + 2 E^NTUC γ δ^5 -
2 NTUC pc δ (NTUC^2 - δ^2) Cos[δ] -
E^NTUC NTUC pc δ (NTUC^2 + δ^2) Cos[
2 θ] -
E^NTUC NTUC^3 pc δ Cos[2 (δ + θ)] -
E^NTUC NTUC pc δ^3 Cos[2 (δ + θ)] +
2 NTUC^3 pc δ Cos[δ + 2 θ] +
2 NTUC pc δ^3 Cos[δ + 2 θ] +
4 NTUC^2 pc δ^2 Sin[δ] +
E^NTUC NTUC^4 γ Sin[2 θ] +
E^NTUC NTUC^2 pc δ^2 Sin[2 θ] +
2 E^NTUC NTUC^2 γ δ^2 Sin[2 θ] +
E^NTUC pc δ^4 Sin[2 θ] +
E^NTUC γ δ^4 Sin[2 θ] -
E^NTUC NTUC^4 γ Sin[2 (δ + θ)] -
E^NTUC NTUC^2 pc δ^2 Sin[2 (δ + θ)] -
2 E^NTUC NTUC^2 γ δ^2 Sin[
2 (δ + θ)] -
E^NTUC pc δ^4 Sin[2 (δ + θ)] -
E^NTUC γ δ^4 Sin[
2 (δ + θ)])))/((2 α +
Sin[2 β] - Sin[2 (α + β)]) (2 δ +
Sin[2 θ] -
Sin[2 (δ + θ)]) (E^(
2 w γ) (2 E^NTUH NTUH^3 ph α -
2 E^NTUH NTUH ph α^3 +
2 E^NTUH NTUH^2 ph α^3 + 2 E^NTUH ph α^5 +
2 E^NTUH NTUH^4 α γ +
4 E^NTUH NTUH^2 α^3 γ +
2 E^NTUH α^5 γ -
2 NTUH ph α (NTUH^2 - α^2) Cos[α] -
E^NTUH NTUH ph α (NTUH^2 + α^2) Cos[
2 β] -
E^NTUH NTUH^3 ph α Cos[2 (α + β)] -
E^NTUH NTUH ph α^3 Cos[2 (α + β)] +
2 NTUH^3 ph α Cos[α + 2 β] +
2 NTUH ph α^3 Cos[α + 2 β] +
4 NTUH^2 ph α^2 Sin[α] +
E^NTUH NTUH^2 ph α^2 Sin[2 β] +
E^NTUH ph α^4 Sin[2 β] +
E^NTUH NTUH^4 γ Sin[2 β] +
2 E^NTUH NTUH^2 α^2 γ Sin[2 β] +
E^NTUH α^4 γ Sin[2 β] -
E^NTUH NTUH^2 ph α^2 Sin[2 (α + β)] -
E^NTUH ph α^4 Sin[2 (α + β)] -
E^NTUH NTUH^4 γ Sin[2 (α + β)] -
2 E^NTUH NTUH^2 α^2 γ Sin[
2 (α + β)] -
E^NTUH α^4 γ Sin[
2 (α + β)]) (2 E^NTUC NTUC^3 pc δ +
2 E^NTUC NTUC^4 γ δ -
2 E^NTUC NTUC pc δ^3 +
2 E^NTUC NTUC^2 pc δ^3 +
4 E^NTUC NTUC^2 γ δ^3 +
2 E^NTUC pc δ^5 + 2 E^NTUC γ δ^5 -
2 NTUC pc δ (NTUC^2 - δ^2) Cos[δ] -
E^NTUC NTUC pc δ (NTUC^2 + δ^2) Cos[
2 θ] -
E^NTUC NTUC^3 pc δ Cos[2 (δ + θ)] -
E^NTUC NTUC pc δ^3 Cos[2 (δ + θ)] +
2 NTUC^3 pc δ Cos[δ + 2 θ] +
2 NTUC pc δ^3 Cos[δ + 2 θ] +
4 NTUC^2 pc δ^2 Sin[δ] +
E^NTUC NTUC^4 γ Sin[2 θ] +
E^NTUC NTUC^2 pc δ^2 Sin[2 θ] +
2 E^NTUC NTUC^2 γ δ^2 Sin[2 θ] +
E^NTUC pc δ^4 Sin[2 θ] +
E^NTUC γ δ^4 Sin[2 θ] -
E^NTUC NTUC^4 γ Sin[2 (δ + θ)] -
E^NTUC NTUC^2 pc δ^2 Sin[2 (δ + θ)] -
2 E^NTUC NTUC^2 γ δ^2 Sin[
2 (δ + θ)] -
E^NTUC pc δ^4 Sin[2 (δ + θ)] -
E^NTUC γ δ^4 Sin[
2 (δ + θ)]) - (-2 E^
NTUH NTUH^3 ph α + 2 E^NTUH NTUH ph α^3 -
2 E^NTUH NTUH^2 ph α^3 - 2 E^NTUH ph α^5 +
2 E^NTUH NTUH^4 α γ +
4 E^NTUH NTUH^2 α^3 γ +
2 E^NTUH α^5 γ +
2 NTUH ph α (NTUH^2 - α^2) Cos[α] +
E^NTUH NTUH ph α (NTUH^2 + α^2) Cos[
2 β] +
E^NTUH NTUH^3 ph α Cos[2 (α + β)] +
E^NTUH NTUH ph α^3 Cos[2 (α + β)] -
2 NTUH^3 ph α Cos[α + 2 β] -
2 NTUH ph α^3 Cos[α + 2 β] -
4 NTUH^2 ph α^2 Sin[α] -
E^NTUH NTUH^2 ph α^2 Sin[2 β] -
E^NTUH ph α^4 Sin[2 β] +
E^NTUH NTUH^4 γ Sin[2 β] +
2 E^NTUH NTUH^2 α^2 γ Sin[2 β] +
E^NTUH α^4 γ Sin[2 β] +
E^NTUH NTUH^2 ph α^2 Sin[2 (α + β)] +
E^NTUH ph α^4 Sin[2 (α + β)] -
E^NTUH NTUH^4 γ Sin[2 (α + β)] -
2 E^NTUH NTUH^2 α^2 γ Sin[
2 (α + β)] -
E^NTUH α^4 γ Sin[
2 (α + β)]) (-2 E^NTUC NTUC^3 pc δ +
2 E^NTUC NTUC^4 γ δ +
2 E^NTUC NTUC pc δ^3 -
2 E^NTUC NTUC^2 pc δ^3 +
4 E^NTUC NTUC^2 γ δ^3 -
2 E^NTUC pc δ^5 + 2 E^NTUC γ δ^5 +
2 NTUC pc δ (NTUC^2 - δ^2) Cos[δ] +
E^NTUC NTUC pc δ (NTUC^2 + δ^2) Cos[
2 θ] +
E^NTUC NTUC^3 pc δ Cos[2 (δ + θ)] +
E^NTUC NTUC pc δ^3 Cos[2 (δ + θ)] -
2 NTUC^3 pc δ Cos[δ + 2 θ] -
2 NTUC pc δ^3 Cos[δ + 2 θ] -
4 NTUC^2 pc δ^2 Sin[δ] +
E^NTUC NTUC^4 γ Sin[2 θ] -
E^NTUC NTUC^2 pc δ^2 Sin[2 θ] +
2 E^NTUC NTUC^2 γ δ^2 Sin[2 θ] -
E^NTUC pc δ^4 Sin[2 θ] +
E^NTUC γ δ^4 Sin[2 θ] -
E^NTUC NTUC^4 γ Sin[2 (δ + θ)] +
E^NTUC NTUC^2 pc δ^2 Sin[2 (δ + θ)] -
2 E^NTUC NTUC^2 γ δ^2 Sin[
2 (δ + θ)] +
E^NTUC pc δ^4 Sin[2 (δ + θ)] -
E^NTUC γ δ^4 Sin[2 (δ + θ)])));
I mention below definitions that may be used but I failed in employing them using Simplify. The command kept running and finally spitted out the same expression. I have already tried some previous answers such as one here but failed. Any help is appreciated.
u == (L/2) - (L/4) (Sin[2 α + 2 β] - Sin[2 β])
v == (l/2) - (l/4) (Sin[2 δ + 2 θ] - Sin[2 θ])
I1 == (L/α) (Cos[β] - Cos[α + β])
I2 == (l/δ) (Cos[θ] - Cos[δ + θ])

Related

Implementing rules on functions in Mathematica

Suppose you have the following expression:
expr = f[p^(3) * q^(5) * m] * f[p^(-2) * q^(-5) * m] * f[p^(1/2) * q^(1) * m] + 5 * f[p^(1) * q^(2) * n] * f[q^(-2) * n] + s * f[p^(h) * q^(r) * j] * f[p^(1-h) * q^(-r) * j].
Moreover, suppose that the function f is such that
f[p^(a) * q^(b) * x] * f[p^(1-a) * q^(-b) * x] == 1
for any value (numerical or symbolic) of the exponents a,b and for any x.
This means that
expr == f[p^(1/2) * q^(1) * m] + 5 + s.
How can I teach Mathematica to recognise this property of f and then simplify expr according to it?
I tried to implement it as the following rule
/.f[p^(a_)*q^(b_)*x_]f[p^(1-a_)*q^(-b_)*x_]->1
but it doesn't work. It only works if you specify the numerical value of the exponents a and b, but not if you want them to be generic.
What is the right way to write such a rule?
The answer here may provide a solution : How to insert a subexpression into a larger expression in Mathematica? c/o Rojo
For example, using your expression expr and a larger expression A
expr = f[p^(a)*q^(b)*x] f[p^(1 - a)*q^(-b)*x];
A = 3 expr + z (f[p^(a)*q^(b)*x]) + y expr
doThat[expr_, vars_List] := Expand[Simplify[expr /. Flatten[
Solve[# == ToString##, First#Variables##] & /# vars]],
Alternatives ## ToString /# vars] /.
Thread[ToString /# vars -> vars];
done = doThat[A, {expr}];
ans = Simplify[done //. expr -> 1]
3 + y + z f[p^a q^b x]
The expected answer.
For general cases as per the comment, a pattern can be used, e.g.
expr = f[p^(a)*q^(b)*x] f[p^(1 - a)*q^(-b)*x];
A = 3 expr + z (f[p^(a)*q^(b)*x]) +
y f[p^(h)*q^(l)*x] f[p^(1 - h)*q^(-l)*x];
done = doThat[A, {expr}];
ans = Simplify[done //.
f[p^(a_)*q^(b_)*x] f[p^(1 - a_)*q^(-b_)*x] -> 1]
3 + y + z f[p^a q^b x]
But in the end it can simply be done by
A /. f[p^(a_)*q^(b_)*x] f[p^(1 - a_)*q^(-b_)*x] -> 1
3 + y + z f[p^a q^b x]
2nd edit
A = (3 f[p^(a)*q^(b)*x] f[p^(1 - a)*q^(-b)*x] +
z (f[p^(a)*q^(b)*x]) +
y f[p^(h)*q^(l)*x] f[p^(1 - h)*q^(-l)*x] f[p m])
A /. h -> 2 /. f[p^(a_)*q^(b_)*x_] f[p^(1 - a_)*q^(-b_)*x_] -> 1
3 + z f[p^a q^b x] + y f[m p] f[(q^-l x)/p] f[p^2 q^l x]
When h is 2 the second replacement no longer applies to the expression containing p^(1 - h) because the form has become p^(-1).
On the other hand, keeping the variables symbolic by using Z instead of 2
A /. h -> Z /. f[p^(a_)*q^(b_)*x_] f[p^(1 - a_)*q^(-b_)*x_] -> 1
3 + y f[m p] + z f[p^a q^b x]

Instantiation fault ECLiPSe CSP

I have problems with my CSP under ECLiPSe. I wish to add a constraint to my cryptogram which requires that the number represented by TWO is divisible by 2.
[eclipse 11]: test(Xs).
instantiation fault in (_268{[1..4]}*100 + _200{[0..9]}*10 + _302{[0..9]}*1) mod 2#=0
Abort
Thanks for your help.
My code :
/*
T W O
+ T H R E E
+ T H R E E
---------
E I G H T
*/
:- lib(fd).
myCsp(Xs):-
Xs=[W,I,G,H,T,R,O,E],
Xs::0..9,
[C1,C2,C3,C4]::0..2,
T #> 0,E #> 0,
O + E + E #= C1*10 + T,
W + E + E + C1 #= C2*10 + H,
T + R + R + C2 #= C3*10 + G,
H + H + C3 #= C4*10 + I,
T + T + C4 #= E,
(T*100 + W*10 + O*1) mod 2 #= 0,
alldifferent([W,I,G,H,T,R,O,E]).
test(Xs):-
myCsp(Xs),
labeling(Xs).
The mod/2 operation in
(T*100 + W*10 + O*1) mod 2 #= 0
isn't supported. You can rewrite the line as
T*100 + W*10 + O*1 #= 2*_
which says that the left hand side expression is equal to twice an anonymous integer variable, and thus a multiple of two.

DSolve answers with DSolve

I'm trying this code
g2[x_] = 1/(2 a (a^2 - b^2)) (-a b^2 ϕ1[x] - b^2 ϕ2[x] + a ϕ3[x] + ϕ4[x]) + c2[x];
g4[x_] = 1/(2 a (a^2 - b^2)) (-a^2 b ϕ1[x] - a^2 ϕ2[x] + b ϕ3[x] + ϕ4[x]) + c4[x];
DSolve[{h1[t] + g2[a t] + h3[t] + g4[b t] == μ1[t],
h1'[t] + g2'[a t] + h3'[t] + g4'[b t] == μ2[t]}, {h1[t], h3[t]},t]
But Mathematica's response is DSolve duplicate
DSolve[{c2[a t] + c4[b t] + h1[t] +
h3[t] + (-a b^2 [Phi]1[a t] - b^2 [Phi]2[a t] +
a [Phi]3[a t] + [Phi]4[a t])/(
2 a (a^2 - b^2)) + (-a^2 b [Phi]1[b t] - a^2 [Phi]2[b t] +
b [Phi]3[b t] + [Phi]4[b t])/(2 a (a^2 - b^2)) == [Mu]1[t],
Derivative[1][c2][a t] + Derivative[1][c4][b t] +
Derivative[1][h1][t] +
Derivative[1][h3][t] + (-a b^2 Derivative[1][[Phi]1][a t] -
b^2 Derivative[1][[Phi]2][a t] + a Derivative[1][[Phi]3][a t] +
Derivative[1][[Phi]4][a t])/(
2 a (a^2 - b^2)) + (-a^2 b Derivative[1][[Phi]1][b t] -
a^2 Derivative[1][[Phi]2][b t] + b Derivative[1][[Phi]3][b t] +
Derivative[1][[Phi]4][b t])/(2 a (a^2 - b^2)) == [Mu]2[
t]}, {h1[t], h3[t]}, t]
What am I doing wrong?
By combining your responses to people's questions when you posted this yesterday and again today on mathematica.stackexchange.com, by inspection the solution to your system is
{h1[t] + g2[a t] + h3[t] + g4[b t] == μ1[t], μ2[t] == μ1'[t]}
because your second equation inside DSolve is simply the derivative of your first, as long as μ2[t] == μ1'[t]. That uses all the available information to "solve" your system and without more information I don't believe anything more can be done. At the moment I don't see a way to coax DSolve into seeing this is the solution.

Using alternative special functions in Simplify and Expand

I have Mathematica expressions involving the special functions Erf[x] and Erfc[x], but I'd like to express them in terms of the scaled and translated version
F[x_] := CDF[NormalDistribution[0,1]][x]
throughout the notebook. This is because F[x] has an easy interpretation in the context of my problem.
Not sure whether I understand your problem, but I'm trying to answer my interpretation of what your saying.
So you have an expression in erf and erfc, like this
expr = Erf[x] + 1/Erfc[x] + Sin[Erf[x]] + Cos[Erfc[x]]
All it takes to replace erf and erfc with F is this:
expr //. {Erfc[x_] -> 2 F[-(x) Sqrt[2]], Erf[x_] -> 1 - Erfc[x]}
(* ==> 1 + Cos[2 F[-Sqrt[2] x]] + 1/(2 F[-Sqrt[2] x]) -
2 F[-Sqrt[2] x] + Sin[1 - 2 F[-Sqrt[2] x]]
*)
which with your definition of F[x] is indeed the same:
1 + Cos[2 F[-Sqrt[2] x]] + 1/(2 F[-Sqrt[2] x]) - 2 F[-Sqrt[2] x] +
Sin[1 - 2 F[-Sqrt[2] x]] /. F[x_] -> CDF[NormalDistribution[0, 1]][x]
(* ==> 1 + Cos[Erfc[x]] + 1/Erfc[x] - Erfc[x] + Sin[1 - Erfc[x]] *)

Collect output of Roots[] into a list

If I do Roots[a x^2 + b x + c == 0, x], the output is
x == (-b - Sqrt[b^2 - 4 a c])/(2 a) ||
x == (-b + Sqrt[b^2 - 4 a c])/(2 a)
How do I collect the output of Roots into a list like so {(-b - Sqrt[b^2 - 4 a c])/(2 a), (-b + Sqrt[b^2 - 4 a c])/(2 a)} so that I can plot it?
An alternative (obvious?} method:
List ## Roots[a x^2 + b x + c == 0, x][[All, 2]]
giving
x /. {ToRules[Roots[a x^2 + b x + c == 0, x]]} // Flatten
==> {(-b - Sqrt[b^2 - 4 a c])/(2 a), (-b + Sqrt[b^2 - 4 a c])/(2 a)}

Resources