New answers tagged

3

Integrate[Exp[-s x] Cosh[a x], {x, 0, ∞}, Assumptions -> s > Abs[a] && a ∈ Reals] $\frac{s}{s^2-a^2}$ Note that this is the Laplace transform: LaplaceTransform[Cosh[a x], x, s] $\frac{s}{s^2-a^2}$ Your problem was that you were trying to integrate a "function" that included the logical expression && when that was actually a ...


4

Get the MNIST digit recognition data set (70,000 hand-drawn digits with classifications): totalSet = ExampleData[{"MachineLearning", "MNIST"}, "Data"]; Divide it into training set, validation set (used to find optimum values for hyperparameters, such as regularization constants) and test set (which is not used in building the classifier at all, but which ...


3

You want to hunt down the error? Here is the best piece of advice: don't plot a function until you know it works. Okay, that's out of the way, now let's go through the process of finding out why your code gives an error. First we can look at just one integral, Λ = 10^-6; Δ = 10^-3; θ = 1/2 ArcTan[Δ/δ]; h = 10^-1; t = 10^3; s = -h Sqrt[Δ^2 + δ^2] ...


6

The solution is a straightforward application of Integrate. Integrate[Exp[-((x - x0)^2 + (y - y0)^2)/(2 c) - I (kx x + ky y)], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}, Assumptions -> c > 0] (* 2 c E^(-(1/2) c (kx^2 + ky^2) - I (kx x0 + ky y0)) π *)


5

Examine your integrand (which is suggested by the error, after all). PiecewiseExpand will collect all terms under one piecewise function. c*h[c, k1, t1]*(1 - H[c, k2, t2])*(1 - H[c, k3, t3]) // PiecewiseExpand (* Power::infy, Infinity::indet errors... *) You can see that the function does not have numeric values for c > 1. How to fix it is ...


4

Perhaps useful I think this substitution provides a preferable form for the numerical integration: exp = ((w E^(-w/a) Sin[((w - s)^2)/2])/((w - s)^2)/2 /. w -> -a Log[g]) D[-a Log[g], g] f[b_?NumericQ] := Block[{a = 10^-6, s = -10^(-1) Sqrt[10^(-3)^2 + b^2]}, - a^2 NIntegrate[exp/a^2, {g, 0, 1}, WorkingPrecision -> 30, ...


4

Evaluating the integral analytically seems to take far too long on my machine, so I aborted it. Since you mention that you studied the integrated expression, perhaps you could consider showing result you got from the integration in your question. Having said that, numerical integration suggests that the values of the integral are very small over a wide ...


2

Some of the definitions in the original question were problematic. I edited the question to have more consistent code. In order to plot the function numerical values are needed, so using Integrate is not necessary. We can use NIntegrate instead. The plot is produced within 30 seconds on my laptop with Mathematica 10.3.1. Here is the function redefined: ...


4

I would suggest adding option GenerateConditions->False to Integrate to speed up the integration. Then, instead of D, use Derivative. Then, to generate a SeriesData apply Series: f[x_] := 1/x; max = 4; em[n_Symbol] := Series[Integrate[f[x], {x, 1, n}, GenerateConditions -> False] + (f[1] + f[n])/2 + Sum[BernoulliB[2 k]/(2 k)! (Derivative[2 ...


1

If numerical results are acceptable; Needs["NumericalCalculus`"] func[θ1_,n_]:= 1/2 ((n Cos[θ1] - 0.2 Sqrt[1 - 25. n^2 Sin[θ1]^2])^2/(n Cos[θ1] + 0.2 Sqrt[1 - 25. n^2 Sin[θ1]^2])^2 + (-0.2 Cos[θ1] + n Sqrt[1 - 25. n^2 Sin[θ1]^2])^2/(0.2 Cos[θ1] + n Sqrt[1 - 25. n^2 Sin[θ1]^2])^2) int[n_?NumberQ] := int[n] = NIntegrate[func[\[Theta]1, n], ...


2

This is more a long comment than an answer. If you calculate: D[x Hypergeometric2F1[1/2, 2/3, 3/2, x^2], x] FullSimplify@D[x/Sqrt[1 - x^2], x] You find respectively: 1/(1 - x^2)^(2/3) and 1/(1 - x^2)^(3/2) Mathematica gives the correct answer: Check the exponents!!


1

This is what I get on OS X 10.3.1 (64bit)


2

A "nice" result is confirmed, but it is not the one hoped for in the OP but that of george2079 and others here. An analysis is made on the basis of the fundamental theorem of calculus. Here no error messages appear but the slight uncertainty is now shifted to the hypothesis of continuity of the antiderivative. This in turn seems pretty obvious from plotting ...


0

Interesting problem. Let us dwell a little bit on that and calculate the distribution function (PDF) of the two-fold random factor given by t = u^v where u is assumed here - as an example - to be exponentially distributed and v takes the values +1 or -1 with equal probability 1/2. The PDF is given by f[t_] := Integrate[ Exp[-u] (DiracDelta[t - u] + ...


2

Observing strictly that the domain of x as the upper limit of the summation index is the integers, the limit exists, it can be calculated easily with Mathematica and it is different from zero. We need to consider this sum \[Sigma]WH[x_] := Sqrt[\[Pi]^2/12 + Simplify[Sum[(x!*x!)/(k!*(2 x - k)!)*(-1)^(x - k)/(x - k), {k, 0, x - 1}], x \[Element] ...


3

I'm a little bit late to this party, but I had written this function for another question that turned out not to need it, so I'll put this here. My strategy is to straightforwardly calculate the integral via $$ \begin{align} \int f(\vec x) &\, \exp\left( - \frac 1 2 \sum_{i,j=1}^{n}A_{ij} x_i x_j \right) d^nx = \\ & \sqrt{(2\pi)^n\over \det A} \, ...


4

The problem occurs because of apparently complex form of the expression beyond the integral of Sin[s^k]. Nevertheless it is not too harmful to proceed. Adequate limits are real and we don't need playing to simplify complex expressions to explicitly real forms. We can calculate the both integrals with appropriate assumptions: f[x_, k_] = Integrate[{ ...


2

Mathematica knows how to simplify when a is exactly 2*Pi: (-b*Cos[a*b] Sin[a/2] + Sin[a*b] Cos[a/2])/(b^2 - 1) /. a -> 2*Pi // InputForm -(Sin[2*b*Pi]/(-1 + b^2)) It then applies the numerical limit for b=1. For the approximate number 2.*Pi, Mathematica can't make this simplification, and it turns out the limit is +Infinity for a<2*Pi and ...


1

To sum up what we have been saying in comments, it may sometimes be dangerous to use symbolic solvers (e.g. Integrate) with inexact input (e.g. $d=0.1$). It is better in your case to evaluate the integral symbolically, and then calculate the approximate numerical value: a = 10^-6; b = 10^-3; c = 1; s = -d Sqrt[b^2 + c^2]; d = 1/10; Integrate[(w ...


2

In your inputs a = 10^-6; b = 10^-3; c = 1; d = 0.1; s = -d Sqrt[b^2 + c^2] -0.1 this result is approximated for display. You can see the complete result by placing your cursor in front of the -0.1 and pressing the space bar. Alternatively InputForm[s] -0.1000000499999875 Edit With s = -d Sqrt[b^2 + c^2] the integral calculation yields ...


3

I think you will have to ask a mathematician if the limit is really 0 (or even real) since in Mathematica you can get this s[x_] := Sqrt[ Pi^2/12 + Sum[(x!*x!)/(k!*(2 x - k)!)*(-1)^(x - k)/(x - k), {k, 0, x - 1}]] s[x] // FullSimplify Limit[s[x], x -> Infinity] // FullSimplify So the limit seems to be complex, but I am not sure, I am not a ...


2

The copyable code you omitted: res = Integrate[(1 - Exp[h *(s - T)])^4/(k2 - k1* Exp[(s - T)*(2 h)])^2, s, Assumptions -> Element[k1 | k2, Reals] && k1 < 0 && k2 < 0] You are surprised to see a term $\sqrt{k1}$ pop up in the answer, with k1 defined as being negative. You don't specify why you see that as a problem, so I have ...


5

linearizeEquation[expr_, f_, fp_, order_] := Block[{e}, Expand@Normal@Series[expr /. f -> (fp + e dF[#] &), {e, 0, order}] /. e -> 1 ] linearizeEquation[f[x] + (1 - f[x]^2) + D[f[x], {x, 2}] + f[x] D[f[x], x], f, f0, 1] (* 1 + f0 - f0^2 + dF[x] - 2 f0 dF[x] + f0 dF'[x] + dF''[x] *)


2

As @bbgodfrey commented, if the integrals in the equation in the OP's FindRoot command can be evaluated before passing the equation to FindRoot, one can save a lot of time. It seems there is still more to be done. I found FindRoot struggles to find an accurate root in some areas of the domain of the equation. It turns out one can use Solve to solve the ...


0

Λ = 10; Ω = 10; t = 1; expr = Integrate[ω E^(-ω/Λ) Sin[(ω + \ Ω) t/2]^2/(ω + Ω)^2, {ω, 0, ∞}] (* Cos[10]/2 - (1/4)*E*((10 + I)*Pi + 4*ExpIntegralEi[-1] - (1 - 10*I)*ExpIntegralEi[ -1 + 10*I] + Gamma[0, 1 - 10*I] + (2 + 10*I)* Gamma[0, 1 + 10*I]) *) expr // N // InputForm (* 0.5919207759524217 - ...


2

Λ = 10; Ω = 10; k[t_] := k[t] = NIntegrate[ω E^(-ω/Λ) Sin[(ω + Ω) t/2]^2/(ω + Ω)^2, {ω, 0, ∞}] Plot[k@t, {t, 0.01, 1}, MaxRecursion -> 1, PlotPoints -> 20]


5

Depending on the distribution desired, you could use the log-normal (or a similar transformation of whatever distribution has a mean of 0). It is transformed distribution such that a value -y < 0 of the underlying distribution is transformed to 1/x iff the value y > 0 is transformed to x (i.e., Exp[-y] == 1/x where x = Exp[y]). The "underlying" ...


2

You can accomplish something very similar to your pseudo-code by defining a function: rand := RandomChoice[{Times, Divide}] Now every time you call the rand function, it either multiplies or divides its two arguments. For example, rand[3, 4] returns 12 half the time and 3/4 the other half. Now you can replace the "4" with a randomly chosen number and ...


1

This gives slightly different results than the other solutions ( if you Listplot large data points) RandomChoice[{RandomReal[{1/10, 1}], RandomReal[{1, 10}]}]


16

I would approach this from the fact that both are forms of multiplication, but one has a negative exponent. So RandomReal[{1, 20}]^RandomChoice[{1, -1}] will randomly be either 1/x or x, where x is a random number between 1 and 20.


4

One way: RandomChoice[{Times[x, #] &, Divide[x, #] &}][RandomReal[{1, 20}]] To repeat, use a Table or Do expression, etc.


4

This was done in V10.3.1. Integrate[(-2 a Cos[π/24] Gamma[11/12] HypergeometricPFQ[{11/24, 23/24}, {2/3, 4/3}, (4 a^3)/27] + 8 Gamma[5/4] HypergeometricPFQ[{1/8, 5/8}, {1/3, 2/3}, (4 a^3)/27] Sin[π/8] + a^2 Gamma[19/12] HypergeometricPFQ[{19/24, 31/24}, {4/3, 5/3}, (4 a^3)/27] Sin[(5 π)/24]), {a, 0, ∞}] (864/665) Sqrt[2 (4 + ...


0

When you define your function like this, then e.g. ffd[.5, .5, .5] is really D[ff[.5, .5, .5], {{.5, .5, .5}}]. to avoid scoping issues with x=5; ffd[x_, y_, z_] = D[ff[x, y, z], {{x, y, z}}] you can use ffd = Evaluate[D[ff[#, #2, #3], {{#, #2, #3}}]] & & means there is a held Function so we have to use Evaluate to force computation of ...


1

With ffd[x_,y_,z_]:= D[ff[x,y,z],{{x,y,z}}] the values of x, y, and z are substituted as arguments causing differentation wrt. numbers, i.e. nonsense. Moreover, you are using SetDelayed, which differentiate once for every call, which rather should be once for all time. The solution to both problem is replacing SetDelayed with Set: ffd[x_,y_,z_]= ...



Top 50 recent answers are included