Oh boy, it's hard to fix this at the top level. It should be easy for WRI to fix, though. I hope you've reported it. If we fix Periodic`PeriodicFunctionPeriod to return nonnegative periods, Maximize will work properly. The internal code has somewhat complicated pattern constraints on the definitions. I couldn't get the Villegas-Gayley technique to work, so I added an Abs* a real-only version of absolute value to the top-level internal function.
Block[{Periodic`PeriodicFunctionPeriod},
Periodic`PeriodicFunctionPeriod[Periodic`PeriodicFunctionDump`expr__] /;
Periodic`Private`PDValidExpressionQ[{Periodic`PeriodicFunctionDump`expr}] :=
Block[{Periodic`PeriodicFunctionDump`res},
Periodic`PeriodicFunctionDump`res =
Periodic`PeriodicFunctionDump`periodicFunctionPeriod[Periodic`PeriodicFunctionDump`expr];
If[Quiet[TrueQ[# < 0]], -#, #] &@ Periodic`PeriodicFunctionDump`res /; (* <-- the "fix" *)
FreeQ[Periodic`PeriodicFunctionDump`res, $Failed]];
Maximize[Cos[1 - x], x]
]
(*
{1, {x -> 1}}
*)
I cannot be sure that such a fix won't break something. It could be that a "negative period" is a sign of something that is used somewhere inside Mathematica. Mathematically speaking, the period should be a positive number.
The problem, as I mentioned in a comment, is that negative coefficients on x results in a negative period:
Periodic`PeriodicFunctionPeriod[Cos[1 - x], x]
(* -2 π *)
Maximize checks that the period is between 0 and Infinity. (So Maximize is assuming the mathematical notion of period.) Since it's not, the period is discarded and the equation for the critical points is solved using Reduce without the constraint of the period. Reduce produces the indeterminate result:
Reduce[D[Cos[1 - x], x] == 0, x, Reals, WorkingPrecision -> ∞]
(* C[1] ∈ Integers && (x == 1 - 2 π C[1] || x == 1 - π - 2 π C[1]) *)
ToRules is applied to this. Maximize assumes that if it does not evaluate to rules, then the problem has not been solved. ToRules returns unevaluated. In any case that's the nature of the bug. It looks easy to fix (for WRI).
Update note -- I just realized my comment shows that it is possible to have complex-imaginary periods. This might lead to a case where the original fix of applying Abs to the period would mess things up. I changed the fix so that only negative real numbers have their sign changed.
Maximize[Cos[x - 1.], x]giving{1., {x -> 1.}}– Nasser Jan 24 '15 at 22:59NMaximize[Cos[x - 1], x], gives the same answer. – Chen Stats Yu Jan 24 '15 at 23:15Be that as it may: Call
– Jinxed Jan 25 '15 at 00:10TrigExpand[], thenMaximize[]//Simplifyon the second one.NMaximizeand numerically finding a maximum in your example. – DumpsterDoofus Jan 25 '15 at 00:12Maximizeto it, thinking I would get the answer. Hilarity ensued. – DumpsterDoofus Jan 25 '15 at 00:16Maximizecalculates the period as-2 πwhich it rejects since it does not satisfy0 < -2 π < Infinity. Without the constraint, it gets toToRules[C[1] ∈ Integers && x == 1 - 2 π C[1]], which it rejects since it does not evaluate to rules. – Michael E2 Jan 25 '15 at 01:24Sin[x]asSolve[f[x + k] == f[x] && k != 0, k]it doesn't work in a straightforward way becauseArcSin[Sin[x]]does not simplify asx– Dr. belisarius Jan 25 '15 at 15:45