2
$\begingroup$

The command

Plot[Log[27, Sin[2*x] - 1/3*Cos[x]] - 1/3*Log[3, -Cos[x]], {x, -Pi, Pi}]

performs

enter image description here

However, this result contradicts both calculus over the reals, where $\log_3(-\cos x)$ is not defined for $x\ge-\frac \pi 2, x\le \frac \pi 2,$ and the result of

Solve[Log[27, Sin[2*x] - 1/3*Cos[x]] - 1/3*Log[3, -Cos[x]] == 0 &&
  x >= -Pi && x < Pi, x, Reals]

{{x -> -2 ArcTan[3 + 2 Sqrt[2]]}}

The question arises: how to fix this discordance?

$\endgroup$
0
2
$\begingroup$
f = Module[{l}, l = Log[#, ConditionalExpression[#2, #2 > 0]] &; With[{Log = l}, #]]&;

f @ Unevaluated @ Plot[Log[27, Sin[2*x] - 1/3*Cos[x]] - 1/3*Log[3, -Cos[x]], {x, -Pi, Pi}]

enter image description here

Alternatively,

g = ConditionalExpression[#, Simplify[FunctionDomain[#, x] /. C[1] -> 0]]&;

Plot[Evaluate[g@Log[27, Sin[2*x] - 1/3*Cos[x]] - 1/3*Log[3, -Cos[x]]], {x, -Pi,  Pi}]  

same picture

$\endgroup$
4
  • $\begingroup$ Thank you. This works well. However, the main work is done by hand, not automatically. I think the FunctionDomain command works better here. $\endgroup$ – user64494 Sep 7 '18 at 7:03
  • $\begingroup$ @user64494, added a variant that uses FunctionDomain. $\endgroup$ – kglr Sep 7 '18 at 7:38
  • $\begingroup$ Thank you again. I am interested in a simple answer: students are not two-headed. $\endgroup$ – user64494 Sep 7 '18 at 7:40
  • $\begingroup$ Your answer is professionally done and automated. Unfortunately, its understanding is difficult for undegraduate students. It is impossible to accept two answers simultaneously. Because of this reason I abstain of its accepting as yet. $\endgroup$ – user64494 Sep 7 '18 at 14:14
1
$\begingroup$

Your plotfunction is real if both Log-arguments are >0. Perhaps using RegionFunctions might help solving your problem:

Plot[ Log[27, Sin[2*x] - 1/3*Cos[x]] -1/3*Log[3, -Cos[x]] , {x, -2 Pi, 2 Pi},PlotRange -> {{-2 Pi, 2 Pi}, Automatic},PlotLabel -> "both log arguments >0", 
RegionFunction ->Function[x, (Sin[2*x] - 1/3*Cos[x] > 0) && ( -Cos[x] > 0)] ]

enter image description here

addition

But the sum of two comlex numbers might although evaluate to real, if the summands are complex:

Plot[{ #, Im[#]} &[Log[27, Sin[2*x] - 1/3*Cos[x]] - 1/3*Log[3, -Cos[x]]] // Evaluate, {x, -2 Pi, 2 Pi}, PlotStyle -> {{ Red}, Green }]

enter image description here

and that's the result MMA calculates in the first plot of the question.

By the way it's identical to the use of RegionFunction -> Function[{x, y}, Im[y] == 0]

Plot[ Log[27, Sin[2*x] - 1/3*Cos[x]] -1/3*Log[3, -Cos[x]] , {x, -2 Pi, 2 Pi}, PlotRange -> All, 
RegionFunction -> Function[{x, y},  Im[y] == 0], PlotRange -> All, PlotLabel -> "Im==0"]
$\endgroup$
5
  • $\begingroup$ Thank you. This works well. However, main work is done by hand, not automatically, so I wiil be waiting for other answers some time before accepting your answer.. $\endgroup$ – user64494 Sep 7 '18 at 6:35
  • $\begingroup$ Your answer is clear and understable to undegraduate students. However, its main part is done rather by hand. Unfortunately, it is impossible to accept two answers simultaneously. Because of this reason I abstain of its accepting as yet. $\endgroup$ – user64494 Sep 7 '18 at 14:15
  • $\begingroup$ @user64494 Thanks for your reply. If you look at the last code line in my answer you might recognize , that it is quite straight forward(nothing made by hand...) $\endgroup$ – Ulrich Neumann Sep 7 '18 at 14:31
  • $\begingroup$ Yes, it is a direct code. Unfortunately, this code does not produce the required plot. $\endgroup$ – user64494 Sep 7 '18 at 17:03
  • $\begingroup$ @ user64494 What is the required plot? Should the plotfunction be real? If yes it is the required plot!!! Or should the several log-functions be simultanously real? If so, the answer of kglr and the first result of my answer is what you are looking for!!!! $\endgroup$ – Ulrich Neumann Sep 7 '18 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.