# Tag Info

33

The primary difference between Refine and the two *Simplify functions is that Refine only evaluates the expression according to the assumptions given. It might so happen to be the simplest form when evaluated, but it does not check to see if it is indeed the simplest possible form. You should use Refine when your goal is not to simplify the expression but to ...

30

Edit: I added more explanations below, because this visualization method is quite different from conventional vector plots For just this purpose I had at some point invented the following visualization technique. I'll reproduce your definition first. It defines a complex vector field on the surface of a unit sphere. Clear[ϵ];(*Polarization vector*)ϵ[λ_] = ...

27

(I had been meaning to write a blog entry about this myself, but since this question has come up, I suppose I'll just write about it here instead...) In demonstrating how the quincuncial projection works, consider first the following complex mapping: With[{ω = N[EllipticK[1/2], 20]}, ParametricPlot[{Re[InverseJacobiCN[Tan[φ/2] Exp[I θ], 1/2]], ...

22

Following the advice in comments, I've made a test library for BesselJ[1, #] & function to evaluate via GSL. I still consider it a workaround, so if you find a way to use Mathematica built-in functions with good performance, please do make a new answer. Needs["CCompilerDriver"] besselJ1src = " #include \"WolframLibrary.h\" DLLEXPORT mint ...

20

Borrowing almost verbatim from a recent response about finding extrema, here is a method that is useful when your function is differentiable and hence can be "tracked" by NDSolve. f[x_] := BesselJ[1, x]^2 + BesselK[1, x]^2 - Sin[Sin[x]] In[191]:= zeros = Reap[soln = y[x] /. First[ NDSolve[{y'[x] == Evaluate[D[f[x], x]], y[10] == (f[10])}, ...

19

I might as well elaborate on my comment. Here is a modification of Stan Wagon's FindAllCrossings[] function (from his book Mathematica in Action, second edition) that uses Plot[] to generate the initial approximations to be subsequently polished by FindRoot[]: Options[FindAllCrossings] = Sort[Join[Options[FindRoot], {MaxRecursion -> Automatic, ...

19

Here is a shameless plug for my HTML parser posted here. The code is a bit long to reproduce here, the only change to it I'd do is to replace the function processPosList with this code: processPosList::unmatched = "Unmatched lists 1 enountered!"; processPosList[{openlist_List, closelist_List}] := Module[{opengroup, closegroup, poslist}, {opengroup, ...

18

It is Kampé de Fériet function, introduced in Joseph Kampé de Fériet, "La fonction hypergéométrique.", Mémorial des sciences mathématiques, Paris, Gauthier-Villars. Its definition is given on Notations page: and, in an alternative form, in Wikipedia: $${}^{p+q}f_{r+s}\left( \begin{matrix} a_1,\cdots,a_p\colon b_1,b_1{}';\cdots;b_q,b_q{}'; \\ ... 17 Short story$$ \vartheta(x) = \arg \left[(\operatorname{Bi}x+i \operatorname{Ai}x)e^{-\frac{2}{3} i (-x)^{3/2}}\right]+\frac{2}{3} \operatorname{Re}\left[(-x)^{3/2}\right] $$Update: I see that you want use only real functions, so you can expand this as$$ \vartheta(x) = \begin{cases} \arctan\frac{\cos \left(\frac{2}{3} (-x)^{3/2}\right) ...

17

The built-in function ContinuedFractionK can be used to generate an approximation to R[q] good enough for plotting purposes. r[q_, n_] = q^(1/5) ContinuedFractionK[q^i, 1, {i, 0, n}]; r[q, 4] A very reasonable plot can be made with Plot[r[q, 20], {q, 0, 3}]

16

One can use Solve as well, e.g. s = Solve[ BesselJ[1, x]^2 + BesselK[1, x]^2 - Sin[ Sin[x]] == 0 && 0 < x < 10, x] Solve::incs: Warning: Solve was unable to prove that the solution set found is complete. >> {{x -> Root[{BesselJ[1, #1]^2 + BesselK[1, #1]^2 - Sin[Sin[#1]] &, 0.886604635313462076794393681674}]}, {x -> ...

16

You need to add ColorFunctionScaling -> False as an option to SphericalPlot3D. That should do the trick color[Θ_, Φ_] := RGBColor[(Sign[Re[SphericalHarmonicY[2, 1, Θ, Φ]]] + 1)/ 2, 0, (-Sign[Re[SphericalHarmonicY[2, 1, Θ, Φ]]] + 1)/ 2]; SphericalPlot3D[ Re[SphericalHarmonicY[2, 1, Θ, Φ]], {Θ, 0, π}, {Φ, 0, 2 π}, ColorFunction -> ...

15

I've had to work with that kind of function (relying on cancellation of large terms) before, and the most practical workaround I could figure out to be able to evaluate the function numerically is to use its power expansion near the point of trouble (here, $+\infty$). So, get a good look at the series expansion and find out how it works (or derive it on ...

15

If you have an analytic formula for f[x_] := Erfc[x]*Exp[x^2] not using Erfc[x] you could do what you expect. However it is somewhat problematic to do in this form because Erfc[x] < $MinNumber for x == 27300.$MinNumber 1.887662394852454*10^-323228468 N[Erfc[27280.], 20] 5.680044213569341*10^-323201264 Edit A very good approximation of ...

15

Following this question you can define: invmollweide[{x_, y_}] := With[{theta = ArcSin[y]}, {Pi (x)/(2 Cos[theta]), ArcSin[(2 theta + Sin[2 theta])/Pi]}]; fc[phi_] := Block[{theta}, If[Abs[phi] == Pi/2, phi, theta /. FindRoot[2 theta + Sin[2 theta] == Pi Sin[phi], {theta, phi}]]]; cart[{lambda_, phi_}] := With[{theta = fc[phi]}, {2/Pi*lambda ...

15

Here's the exact answer: i1 = Integrate[x^n Exp[-(x - a)^2], {x, 0, Infinity}, Assumptions -> n > 0] /. n -> 1/2 (* 1/2 E^-a^2 (Gamma[3/4] Hypergeometric1F1[3/4, 1/2, a^2] + 1/2 a Gamma[1/4] Hypergeometric1F1[5/4, 3/2, a^2]) *) i1 /. a -> 0.3 (* 0.907605 *)

14

This question is not trivial as it would seem and a detailed discussion could help to understand the issue, especially when we deal with roots of special functions, however to do the task as simply as possible this would be the best way : f[x_] := LegendreP[6, x] Reduce[f[x] == 0, x, Reals] == Reduce[f[x] == 0, x] True Reduce[f[x] == 0, x, Reals] ...

14

An experimental internal function IntegrateInverseIntegrate helps here, although it's intended more for integrands involving logs. This is what it returns in the development version: Integrate`InverseIntegrate[Exp[-x Cosh[t]], {t, 0, Infinity}, Assumptions -> Re[x] > 0] (* BesselK[0, x] *)

14

For numerical evaluation, there is the rapidly-converging continued fraction (due to Jones and Thron): $$\exp(x^2)\mathrm{erfc}(x)=\frac{2x}{\sqrt \pi}\cfrac{1}{2x^2+1-\cfrac{1\cdot2}{2x^2+5-\cfrac{3\cdot4}{2x^2+9-\cdots}}},\qquad x > 0$$ One can use the built-in function ContinuedFractionK[] with a suitable cut-off: With[{x = N[30000], n = 10}, -2 x ...

14

The site is not terribly conducive to scraping as the HTML is "noisy" and looks like WRI might change the format at the drop of a hat. Throwing caution to the wind... scrapeWolframFunction[id_] := Import["http://functions.wolfram.com/" ~~ id, "XMLObject"] // Cases[ # , XMLElement["p", {___, "class" -> "CitationInfo", ___}, body_] :> body ...

14

If you modify your TransformationFunction so that it considers numerical values as a special case, you can get both of your examples to work In[1]:= tf[e_] := e /. {BarnesG[x_?NumberQ /; x > 1] :> Gamma[x - 1] BarnesG[x - 1], BarnesG[1 + x_] :> Gamma[x] BarnesG[x]} In[2]:= Simplify[BarnesG[1 + x] - Gamma[x] BarnesG[x], ...

14

Since EllipticTheta[] is a built-in function, and since the Eisenstein series $E_4(q)$ and $E_6(q)$ are expressible in terms of theta functions (I use the nome $q$ as the argument in this answer, but you can convert to your convention by using the relation with the period ratio $\tau$: $q=\exp(2\pi i \tau)$), and since the higher-order Eisenstein series ...

13

To implement what you intended to do, I suggest to take a look at this approach : hermite[0, x_] := 1 hermite[1, x_] := 2 x hermite[n_Integer /; n >= 2, x_] := hermite[n, x] = Expand[2 x*hermite[n - 1, x] - 2 (n - 1) hermite[n - 2, x]] Now you shouldn't have problems anymore. Recalling that there are in Mathematica the Hermite polynomials ...

13

Refine vs Simplify Mathematica is a term rewriting system, whenever we enter an expression, then it is evaluated by term rewriting using (built-in or user-defined) rewrite rules (see e.g. Evaluation) , so by default it "simplifies" some expressions, e.g. : a + b - a b So this makes an impression, that Refine performs some simplifications, although ...

13

The answer is simply that integrating with the assumption that a variable comes from the class of integers is really difficult. What Integrate does with Assumptions -> Element[m, Integers] is try to generically integrate without the assumption and then apply the assumption to the result to try and simplify it. I've asked around about this before and there ...

13

I present in this answer a compiled implementation of one of the simpler algorithms for numerically evaluating a Bessel function of (modestly-sized) integer order and (small to medium-sized) real argument. This uses Miller's algorithm: bessj = With[{bjl = N[Log[1*^16]]}, Compile[{{n, _Integer}, {x, _Real}}, Module[{h, hb, ...

12

There are many ways of coloring functions, to visualize spatial dependence of spherical harmonics one can take advantage of a useful function Rescale, so here is a bit different coloring using also imaginary part of the function : col[θ_, φ_] := RGBColor @ Rescale[{ Re @ #, 0, -Im @ #}]& @ SphericalHarmonicY[2, 1, θ, φ] SphericalPlot3D[ Re[ ...

12

...and now, the answer I promised to write. As I noted in the comments, there is in fact an explicit formula for the RRCF in terms of built-in Mathematica functions, thanks to the deep theory of modular forms: $$\mathcal{R}(q)=\sqrt[5]{q}\frac{\left(q;q^5\right)_\infty \left(q^4;q^5\right)_\infty}{\left(q^2;q^5\right)_\infty \left(q^3;q^5\right)_\infty}$$ ...

12

Since Root objects can be symbolically differentiated, we can find the closed form for its Taylor series (for an explicit n). root = Root[#1^4 - #1 - t &, 1]; coeff = Refine[FunctionExpand[SeriesCoefficient[root, {t, 0, k}]], k >= 0]; Sum[coeff t^k, {k, 0, ∞}] // FullSimplify -t HypergeometricPFQ[{1/4, 1/2, 3/4}, {2/3, 4/3}, -256t^3/27] We can ...

11

First, this is a single equation in two unknowns so we'd expect infinitely many solutions. So, let's try to solve for one variable in terms of the other: Solve[\[Beta]^-a Gamma[a] Sin[a \[Pi]] + E^\[Beta] \[Beta]^(2 a - 1) Gamma[1 - a] Sin[a \[Pi]] == 0, \[Beta]] That message and the appearance of the ProductLog indicates that we simply might not ...

Only top voted, non community-wiki answers of a minimum length are eligible