Joe
Reputation
726
Next privilege 1,000 Rep.
See vote count; VIP usercard
4 15
Impact
~8k people reached

 Jan28 comment Why doesn't FullSimplify get rid of the common factor in this expression? All these suggestions work. I'm not sure how to judge this, but the one involving Cancel seems like the most direct. As for an explanation for this strange behavior, I guess I shouldn't hold my breath. @PinguinDirk - do you want to turn your comment into an answer so I can accept it? Nov15 comment An elegant way to plot a numeric function that returns a list, and have each element in a different color By using ListPlot you're not taking advantage of the adaptive sampling algorithm of Plot. Nov15 comment Plotting the components of a function that returns a list in different colors without redundant evaluations of the function Another related SO question: "Telling Plot to style vector-valued black-box functions in Mathematica" Nov15 comment An elegant way to plot a numeric function that returns a list, and have each element in a different color @Sasha - in the question you linked to the problem is to avoid redundant evaluations of the function, since it is expensive to evaluate (just like in this question, which is already mentioned above). In my question I don't mind redundant evaluations, my problem is coding style. These are two different issues. Oct31 comment Why doesn't Mathematica simplify a square root of an expression that equals a square of a positive real? Great idea! It can be a bit simplified by using just one replacement rule: x_^2 + 2 y_^2 + 2 y_ Sqrt[x_^2 + y_^2] -> (Sqrt[x^2 + y^2] + y)^2. Oct31 comment Why doesn't Mathematica simplify a square root of an expression that equals a square of a positive real? Nice! Then I just add /.{r -> Sqrt[x^2 + y^2], t -> ArcTan[x, y]} and simplify again and I have the simplified expression in my original variables. On the other hand, I have this expression appearing multiple times with different variables instead of x and y, and I'm not sure if your approach can be generalized to such a case. Oct25 comment Is Abs[z]^2 a bad way to calculate the square modulus of z? Awesome analysis! By slightly adjusting your code, I plotted the difference in the error between the functions Abs[z]^2 and Re[z]^2+Im[z]^2 when they are applied to the same argument, and indeed for most of the points you used Abs[z]^2 has a smaller error! This is really weird and counterintuitive to me, but at least now I know. Oct25 comment Why doesn't Mathematica simplify a square root of an expression that equals a square of a positive real? Since I am trying to simplify a very long expression that contains multiple versions of the expression I'm asking about, and I don't want to go through my long expression manually. Oct25 comment Is Abs[z]^2 a bad way to calculate the square modulus of z? Please do feel free to edit my posts, this was never an issue for me! (I corrected the mistakes, thank you :). Oct25 comment Why doesn't Mathematica simplify a square root of an expression that equals a square of a positive real? This is true, but why is the first simplification so hard that Mathematica doesn't find it? And is there a way to make it find it? Aug30 comment Probability and distribution from actual data Jun25 comment Calculating a limit with a result that is discontinuous in the parameters @belisarius - Indeed in the example I gave in the question the different assumptions are equivalent to different directions. However, how about this example: 1/(1 + Exp[ϵ/T]) + 1/(1 + Exp[(ϵ - 1)/T]). Now there are different results for ϵ<0, 0<ϵ<1 and 1<ϵ, and I don't see how your comment applies here. Jun25 comment Calculating a limit with a result that is discontinuous in the parameters @J.M. - You are correct, I will be satisfied, for example, with a Piecewise function as a result. BTW, why did you remove the limits tag from the question? Jun25 comment Calculating a limit with a result that is discontinuous in the parameters @J.M. - Good point, however trying to use the assumption ϵ ∈ Reals still leaves the limit unevaluated (I edited the question to add this). Jun6 comment Plotting the components of a function that returns a list in different colors without redundant evaluations of the function You're right @Mr.Wizard, in your example memoizing saves evaluations, but it does not save two thirds of the evaluations (I got 715 instead of 953). Of course we can't expect exactly two thirds, since there may be some overhead, by I think that even asymptotically we won't get two thirds. Jun6 comment Plotting the components of a function that returns a list in different colors without redundant evaluations of the function From @whuber's comment, I learned that memoizing doesn't actually save function evaluations. Jun6 comment Plotting the components of a function that returns a list in different colors without redundant evaluations of the function You are correct. However, if I still want to plot all the components of f with a number of evaluations more close to 157, I need to use the approach described in @Mr.Wizard's answer. Jun6 comment Plotting the components of a function that returns a list in different colors without redundant evaluations of the function @whuber: My thoughts exactly. It seems that there is no way to make MMA's adaptive algorithm take into account all the values of a certain component that were already calculated as a result of evaluating f for the other components, and that's a shame. If evaluating f three (or more) times the necessary amount is more costly than the evaluations that the adaptive algorithm saves us (which is almost always the case for functions that take reasonably long to evaluate), this answer seems to be the best workaround. Accepted. Jun5 comment Plotting the components of a function that returns a list in different colors without redundant evaluations of the function This is a nice workaround in case there is no way to address the problem directly, and it has the slight disadvantage of memory use. I would like to wait and see if someone comes up with a more direct approach. May31 comment Exporting a dashed plot with a color gradient to a vector graphics format ruins the dashing Nice! I guess that's the best that can be done until Wolfram fixes the bug...