Group Abstract Group Abstract

Message Boards Message Boards

0
|
78 Views
|
4 Replies
|
4 Total Likes
View groups...
Share
Share this post:

How to display the derivative result in the desired form?

Posted 4 days ago
f[x_] = -(((3 Sqrt[E])/2 - x) (1 - Log[2 Sqrt[E] - x])) + (-(Sqrt[E]/
      2) + x) (1 - Log[x])
g[x_] = PowerExpand /@ (D[f[x], {x, 1}] // FullSimplify)

How to display the derivative result in the desired form?

E/((2 Sqrt[E] - x) x) - Log[x (2 Sqrt[E] - x)]

enter image description here

POSTED BY: Bill Blair
4 Replies

A minimum requirement: For the simplify function to combine logarithms, they need to be told the arguments are real through assumptions.

Aside from that, you need to make the desired form seem less complex than the default result. That can be achieved through the ComplexityFunction option.

One solution, that penalizes excessive Log[]s:

f[x_] = -(((3 Sqrt[E])/2 - x) (1 - Log[2 Sqrt[E] - x])) + (-(Sqrt[E]/
      2) + x) (1 - Log[x])
dom = FunctionDomain[f[x],x]
g[x_] = PowerExpand /@ (D[f[x], {x, 1}] //
 FullSimplify[#
  , dom
  , ComplexityFunction -> (LeafCount[#] + 5 Count[#, _Log, Infinity]&)
  ]&)

Oddball solution:

f[x_] = -(((3 Sqrt[E])/2 - x) (1 - Log[2 Sqrt[E] - x])) + (-(Sqrt[E]/
      2) + x) (1 - Log[x]);
g[x_] = PowerExpand /@ (D[f[x], {x, 1}] // FullSimplify);
dom = FunctionDomain[f[x], x]
Collect[
 g[x]/.ln_Log:>Hold[1]ln
 ,Hold[1]
 ,Simplify[#, dom, ComplexityFunction -> LeafCount]&
 ] // ReleaseHold

Note: LeafCount gives a slightly different measure of complexity than the default measure Simplify`SimplifyCount:

Simplify`SimplifyCount[-(E/(x*(-2*Sqrt[E] + x)))]
Simplify`SimplifyCount[E/(2*Sqrt[E]*x - x^2)]
(*
Out[122]= 21
Out[123]= 20
*)

LeafCount[-(E/(x*(-2*Sqrt[E] + x)))]
LeafCount[E/(2*Sqrt[E]*x - x^2)]
(*
Out[126]= 17
Out[127]= 18
*)
POSTED BY: Michael Rogers
Posted 3 days ago

The ComplexityFunction command turns out to be extremely powerful for simplifying results—looks like I need to study its usage seriously. Thanks again for your help.

POSTED BY: Bill Blair

Here are a couple of ways:

g[x] /. Log[a_] + Log[b_] :> Log[a*b] // Apart
Simplify[g[x], 2 Sqrt[E] - x > 0] // Apart
POSTED BY: Gianluca Gorni
Posted 3 days ago

This method is remarkably concise.

POSTED BY: Bill Blair
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard