Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.4K Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Rootfinding

Posted 11 years ago
Attachments:
POSTED BY: Derek Tom

From the documentation for FindRoot:

FindRoot first localizes the values of all variables, then evaluates f with the variables being symbolic, and then repeatedly evaluates the result numerically.

So your warning message is because of this.

If you define

g[y_?NumericQ] := 
 1 - (4 ((Integrate[x/(E^x - 1), {x, 0, y}]/y + y/2) - 1))/y

(which causes FindRoot to skip the symbolic evaluation) and then evaluate

FindRoot[g[y] == 0.395544, {y, -4.}]

You get the desired answer. Buyt also note that the integration can be done analytically:

In[41]:= 1 - (4 ((Integrate[x/(E^x - 1), {x, 0, y}]/y + y/2) - 1))/y

Out[41]= ConditionalExpression[
 1 - (4 (-1 + y/
     2 + (-(\[Pi]^2/6) - y^2/2 + y Log[1 - E^y] + PolyLog[2, E^y])/
     y))/y, E^y <= 1]

So why not use that so that the integration does not need to be done repeatedly. Note the ConditionalExpression (which is the root cause of your problem) so you need to strip the function of this and just be sure that your domain of root finding is consistent with the constraints of the ConditionalExpression. E.g.:

FindRoot[1 - (
   4 (-1 + y/
      2 + (-(\[Pi]^2/6) - y^2/2 + y Log[1 - E^y] + PolyLog[2, E^y])/
      y))/y == 0.395544`, {y, -1.}]
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard