Group Abstract Group Abstract

Message Boards Message Boards

0
|
6K Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Surd vs Sqrt

Posted 10 years ago

I tried two plot commands

Plot[Sqrt[x+1],{x,-3,3},RegionFunction->Function[x,x>=0]]

And

Plot[Surd[x+1,2],{x,-3,3},RegionFunction->Function[x,x>=0]]

The first one worked fine. The second resultd in error messages Surd is not defined for even roots of negative values. >> I am not sure whay. I thought Sqrt[x] and Surd[x,2] were the "same"

POSTED BY: fajad binj
2 Replies

Yes they are the same for x>0. However Mathematica evaluates the function over the full domain first. and the 'masks' it using region function after that. You can check that by checking the EvaluationMonitor

Reap[Plot[Surd[x + 1, 2], {x, -3, 3}, 
  RegionFunction -> Function[x, x >= 0], EvaluationMonitor :> Sow[x], 
  PlotPoints -> 40, MaxRecursion -> 0]]

It shows all the points where Surd gets evaluated. To avoid these errors there are multiple options, specify directly where the function is 'valid':

Plot[Surd[x + 1, 2], {x, -1, 3}]

or just 'gag' Mathematica by telling it to be quiet:

Quiet[Plot[Surd[x + 1, 2], {x, -3, 3}, RegionFunction -> Function[x, x >= 0]]]

@Moderation Team How is this a staff pick? Is that correct?

POSTED BY: Sander Huisman

Surd gives the real value of the n-th root. Sqrt returns the complex result. In case of an even root of a negative number there doesn't exist a real root, in your case, for example, if x=-3 then Surd[x+1,2]=Surd[-2,2] is not defined while Sqrt give you the imaginary result.

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