Simplifying Cosh[a] + Sin[a] + Sinh[a]
One problem seems to be that the only pair of terms in a Plus[t1, t2,...,]
expression that are simplified are the last two. This shows up not only in the starting expression Cosh[a] + Sin[a] + Sinh[a]
(in that order due to the Orderless
attribute of Plus
) but also in TrigToExp
:
TrigToExp[Cosh[a] + Sinh[a] + Sin[a]]
(* 1/2 I E^(-I a) - 1/2 I E^(I a) + E^a *)
When this is simplified we get the original expression back.
Probably it was thought that pointlessly simplifying $n(n-1)/2$ pairs of terms in a long expression would probably slow down simplification too much. Since one pair but not all pairs are checked, I feel this was a deliberate choice. I'd be reluctant to call it a bug, but it certainly is a shortcoming in this case.
A workaround is to create a transformation function that checks all pairs:
ClearAll[allpairs];
allpairs[e_Plus] :=
First@SortBy[e - # + FullSimplify[#] & /@ Subsets[e, {2}], Simplify`SimplifyCount];
allpairs[e_] := e;
FullSimplify[Cosh[a] + Sinh[a] + Sin[a], TransformationFunctions -> {Automatic, allpairs}]
(* E^a + Sin[a] *)
Another workaround, showing that some standard identities are missing from the automatic transformations:
FullSimplify[Cosh[a] + Sinh[a] + Sin[a],
TransformationFunctions -> {Automatic,
# /. Cosh[z_] -> Exp[z] - Sinh[z] &,
# /. Sinh[z_] -> Exp[z] - Cosh[z] &}]
(* E^a + Sin[a] *)
EDIT: As commented on by Kuba
expr = Cosh[a] + Sinh[a] + Sin[a];
Initially assume that a
is real (default for ComplexExpand
)
expr2 = expr // TrigToExp // ComplexExpand
(* E^a + Sin[a] *)
Then check if the expressions are equal for all (complex) values of a
expr == expr2 // Simplify
(* True *)
EDIT 2: Alternatively, since Michael E2 states that Mathematica "simplifies the last two terms in a sum", vary the ordering of the terms
SortBy[Total /@ FullSimplify@Table[TakeDrop[expr, {n}], {n, 3}],
LeafCount][[1]]
(* E^a + Sin[a] *)