Hot answers tagged

10

There is also a newer package, HolonomicFunctions, that has an implementation of Chyzak's generalization of Zeilberger's algorithm. To perform the desired task, use the following commands: smnd = Simplify[ G /. HoldPattern[HypergeometricPFQ[pl_List, ql_List, x_]] :> (Times @@ (Pochhammer[#, k] & /@ pl)) / (Times @@ (Pochhammer[#, k] & /@ ql)...


7

Rule-replacement with x^n_. :> Derivative[n,0][a][y,z] (as done in Kuba's answer) has two drawbacks: if your polynomial has a constant term, then it will not be replaced by the zero-th derivative a[y,z], and if your polynomial is not expanded the result is incorrect. Namely, (1+x)(2+x) becomes (1+a'[y,z])(2+a'[y,z]) rather than 2a[y,z]+3a'[y,z]+a''[y,z] (...


7

First of all you can simplify the integral by the substitution $t\mapsto t/\omega$, which just changes the value by a known factor. After this, the integrand is: (Cos[t]^2 Cos[α + t])/(-1 + A Cos[α + t])^2 Which is integrated to obtain int = Integrate[(Cos[t]^2 Cos[α + t])/(-1 + A Cos[α + t])^2, t]; Plotting the int for some values of A, omega, and ...


6

One problem is that Exp[y] evaluates to Power[E, y], so that the integral does not match the (held) pattern with Exp. Another is that other functions sometimes evaluate to other forms, such as Sin: Sin[Sin[x] + Cos[x] - x] (* -Sin[x - Cos[x] - Sin[x]] *) Here is a fix that works on the example. I added a constant factor c_ to take care of the -1 ...


6

Everything you want in the question can be done by defining the derivative of the Norm: Derivative[1][Norm][z_] := z/Norm[z] D[Norm[x - y], {x}] (* ==> (x - y)/Norm[x - y] *) Simplify[D[Norm[x - y], {y}]] (* ==> (-x + y)/Norm[x - y] *) Here, the syntax I used for the derivatives is such that it would remain valid if x or y were replaced by vectors ...


5

If you provide those important Assumptions to Limit, it will correctly compute that the exponential goes to zero, as you already know: Limit[ -(((-1 + E^((t*α)/(-1 + α)))*x)/α), α -> 1, Direction -> 1, Assumptions -> t > 0 && Element[x, Reals] ] (* x *) This is explained in the documentation for Limit -> Examples -> Options -> ...


5

First we shall define 'the integration on a curve'. Traditionally, this is defined as integration of f.dl where dl is the length of a small part of the curve. So, using t as a medium, we can explicitly write out the curve's function on a complex plane, here let's assume it's z=2 Exp[I t]. Then we can use t, a real number, as the integration variable, which ...


5

The problem appears to be that Mathematica assumes certain values for a and b so that it can use a particular expression to obtain the result. This is not (necessarily) consistent with the assumptions that you supply for Simplify. The solution is to supply the assumptions around the integral, so that they can be accounted for there. I believe that the ...


4

{x, x^2, x^2 + x} /. x^n_. :> Derivative[n, 0][a][y, z]


4

This is a corrected version of poor quality post I originally posted. This is to classify the extreme values using Lagrange multiplier method. The bordered Hessian for 2D case with one constraint is calculated. Projections onto x-z and y-z plane are used just to show the minima and maxima (local and global for constraint): f[x_, y_] := x^3 - x*y + y^2 + 3 ...


4

Rather than define a function, you can define a replacement rule using Hold and RuleDelayed rule = Hold[Integrate[ Exp[p_. Cos[x_] + q_. Sin[x_]]* Sin[a_. Cos[x_] + b_. Sin[x_] - m_. x_], {x_, 0, 2 Pi}]] :> I*Pi*((b - p)^2 + (a + q)^2)^(-m/ 2)*(((p^2 - q^2 + a^2 - b^2) + I*(2*(p*q + a*b)))^(m/2)* BesselI[m, Sqrt[(p^2 +...


3

Michael E2 and Bob have solved the integral. Here is an alternative method which might be of interest as well. I have used the similar method already in How to solve this integration?. We solve the integral transforming it into a complex contour integral which, after a simple binomial expansion, can easily be soved by the Cauchy theorem. The remaining ...


3

How about adding some assumptions (I think the following is reasonable): res = Integrate[(x1 + x2 - 1)*(Boole[ x1 + x2 >= s && x1 >= t1 && x2 >= t2]), {x1, 0, 1}, {x2, 0, 1}]; FullSimplify[res, 0 < s < 1 && 0 < t1 <= t2 < 1] $$\begin{cases} \frac{1}{2} (\text{t1}-1) (\text{t2}-1) (\text{t1}+\text{...


3

We can simplify the derivation of coolwater appreciably by getting rid of the mixture of t and alpha. It turns out that in the present aproach the only jumps of the antiderivative occur at t = Pi which can be easily taken into account. Here we go: $Version (* Out[176]= "10.1.0 for Microsoft Windows (64-bit) (March 24, 2015)" *) In the first step we "...


3

You could try using numerical differentiation from the Numerical Calculus package: Clear[r, fun] Needs["NumericalCalculus`"] r = NDSolve[ {I k'[s] == 20 (s k[s] - (1 - s) (1 - k[s]) (1 + k[s])), k[0] == 1/2}, k, {s, 0, 1} ]; fun[s_] := Abs[(k /. r[[1]])[s]]; Plot[ {10 fun[t], ND[fun[s], s, t, Terms -> 20]}, {t, 0, 1}, PlotLegends -&...


3

Here is a way to do the manipulation. First I define a convenient way to set up vector fields, then I do the dot product and gradient. The main thing is that the application to the vector argument on the right is done element-wise, so that the natural Mathematica operation is Map (/@). To make the order of operations clearer, I also use two different ...


3

Comment Realize that there is a difference between your original nicely printed equations and the code that you have typed. The difference is in the numerator of the function to be integrated. In the nicely typed set of equations you have Δ in the numerator where as in the code you have typed you have Δ0. Original Code Which is correct? Original ...


3

This is a bug due to the use of slots (#1, #2, ...) internally in the implementations of Derivative and of Integrate. Focus first on Derivative. Derivative[1,0][Print] prints #1#2. This means that at least one branch of the code for Derivative involves calling Print[#1,#2]. In your case, Derivative[1,0][f] calls f[#1,#2]. Focus next on Integrate The ...


2

For a closed curve you can parameterise it with the angular variable. First use $x=r cos(\theta),y=r sin(\theta)$ and then find $r=r(\theta)$ from the the curve. So you end up with $x=x(\theta),y=y(\theta)$. First you change your coordinates to polar. Make sure to choose the origin inside the region or else you will not get a [0,2Pi] limit for the angle. I ...


2

As requested, comment made into an answer. The problem was with the integration limits in the OP. The points on the circle satisfy (x-x0)^2 + (y-y0)^2 == R^2 so for a point x in the range [x0-R,x0+R] the limits on y are {y0 - Surd[R^2 - (x-x0)^2,2],y0 + Surd[R^2-(x-x0)^2,2]} I use Surd here because MMA may simplify more easily than with Sqrt, since ...


2

Here's a possible approach: Clear[a, b, c, s, int] a = 4 Cos[af/2]^2; b = 1 - 5 Cos[af/2]^2; c = Cos[af/2]^2; s = Sqrt[a*x^4 + b*x^2 + c]; int[par_?NumericQ] := With[{integrand = s /. af -> par}, NIntegrate[integrand, {x, 0, 1}]] Plot[int[af], {af, -2 Pi, 2 Pi}] Finding the maxima and minima using the int expression is also possible. Let's first ...


2

EDIT It can get more complicated. Look at a contour given by r[t_] := 1 + 2 Cos[t]; Original post The result of the integral for a (reasonable) closed contour is just 2 I times the area enclosed by the contour. Proof: the integral is $$\int \left(z^*+z\right) \, dz$$ Letting $$z=x+i y$$, $$dz=dx+i dy$$ the integral becomes $$\int 2 x (dx + i dy)=...


2

Alternatively, you could do a little complex number algebra for the purpose: kf = NDSolveValue[{I k'[s] == 20 (s k[s] - (1 - s) (1 - k[s]) (1 + k[s])), k[0] == 1/2}, k, {s, 0, 1}]; Plot[{10 Abs[kf[t]], Re[kf[t] Conjugate[kf'[t]]]/Abs[kf[t]]}, {t, 0, 1}, PlotLegends -> {"scaled function", "numerical derivative"}]


2

To some extent (and with some care) this can be done with FeynCalc. At least I used it several times when I needed to compute gradients and divergences of Cartesian vectors. The trick is to work with D-dimensional 4-vectors and take the limit $D \to 3$ at the end. Since FeynCalc doesn't distinguish between upper and lower indices, the results are the same as ...


2

Using an example from the documentation of ListInterpolation: f = ListInterpolation[ Table[Sin[x y], {x, 0, 1, .25}, {y, 0, 2, .25}], {{0, 1}, {0, 2}}] dfdx[u_, v_] := D[f[x, y], x] /. {x -> u, y -> v} dfdy[u_, v_] := D[f[x, y], y] /. {x -> u, y -> v} Manipulate[ Show[{Plot3D[f[x, y], {x, 0, 1}, {y, 0, 2}], Graphics3D[{Red, PointSize[0.03]...


2

Another form I have found useful is: f = ListInterpolation[ Table[Sin[x y], {x, 0, 1, .25}, {y, 0, 2, .25}], {{0, 1}, {0, 2}}] Then one can make derivative functions that can be treated as normal function via dfdx[x_, y_] := Evaluate[D[f[x, y], {x, 1}]] dfdy[x_, y_] := Evaluate[D[f[x, y], {y, 1}]] and the second derivatives d2fdx[x_, y_] := Evaluate[...


1

Please make your question clear. But I think you're simply using f'[x,y] and hope that you can get a result? Try the following code: f = ListInterpolation[ Table[Sin[x y], {x, 0, 1, .25}, {y, 0, 2, .25}], {{0, 1}, {0, 2}}] D[f[x, y], x] Plot3D[Evaluate@D[f[x, y], x], {x, 0, 1}, {y, 0, 2}] for higher order: D[f[x,y],{x,2}] Will this code help? ...


1

I've edited my answer in the linked thread so that it can now be used without modification. Previously, you had to define the functions uv that you wish to differentiate in a more general way, replacing the explicit 0 in their argument with y. The reason is that my earlier answer assumed differentiations are performed on the given function, not on the new ...


1

The function cannot be integrated with unknown n, because its form changes with different values for n: Table[Integrate[Sqrt[2 - Cos[x]] Exp[I n x], x], {n, 0, 3}] 1: 2 EllipticE[x/2, -2], 1/3 (-4 EllipticE[x/2, -2] + 6 EllipticF[x/2, -2] - I Sqrt[2 - Cos[x]] (-5 + 2 Cos[x/2]^2 + Cos[x] + 2 I Sin[x])) 2: 2/15 (I + Cot[x]) (13 ...


1

Here is how to do the contour integral. Shown for some specific parameters. A = 1; B = -1/2; a = 1; f[z_] := (E^(-a z))/(A + B (Cosh[z])) Integrate[f[rz - I Pi], {rz, Infinity, 0}] + Integrate[f[z], {z, -I Pi, I Pi}] + Integrate[f[rz + I Pi], {rz, 0, Infinity}] // Simplify 4/3 I (-3 + 2 Sqrt[3]) Pi You will need to add appropriate assumptions to ...



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