Tag Info

Hot answers tagged

8

Using approximate numbers (e.g. ones with decimal points) can lead to issues with exact solvers such as Integrate. One way around, if the function can be integrated with symbolic parameters, is to use Block to block the numeric values from being substituted until after the integration is complete: Block[{x0, a, b}, Assuming[a > 0 && b > 0 ...


4

Using the final substitution given in the Question with the addition of Method -> "StiffnessSwitching" produces a solution for r2 as large as 7.4, after which even "StiffnessSwitching" is insufficient to treat the equations at f and h very near 1. λ = 625/2048; r1 = 10^-6; r2 = 7.4; eqn = {r^2*D[D[f[r], r], r] == 2 f[r] (1 - f[r]) (1 - 2 f[r]) - ...


4

Use ComplexExpand Integrate[ComplexExpand[Re[Exp[I*Omega*t]]], {t, 0, 2 Pi}] Sin[2*Omega*Pi]/Omega


4

Here's a workaround. I'm not sure why the variables s1[t], s2[t] are not reset in my first answer (see edit history). We can take care of things manually by making s1 and s2 numerical functions. Block[{ti = Log@100, tf = Log@(10^9), a0 = 3.05917*^7, b0 = 3.05242*^7, s1, s2, s10 = 1, s20 = 1}, s1[t_?NumericQ] := s10; s2[t_?NumericQ] := s20; {{sol}, ...


3

The integral over a spherical region is easily performed by Mathematica even analytically. Assuming f=1 and for brevity putting the center of the sphere at the origin: Timing@Integrate[1, {x, -r, +r}, {y, -Sqrt[r^2 - x^2], +Sqrt[ r^2 - x^2]}, {z, -Sqrt[r^2 - x^2 - y^2], +Sqrt[r^2 - x^2 - y^2]}] (*{0.218401, 4 Pi r^3 / 3}*) Assigning a numerical value to ...


3

For your example, I would simply do this: R = 2.3; {x0, y0, z0} = {1.2, 2.3, 3.4}; NIntegrate[1, {x, -R + x0, R + x0}, {y, y0 - Sqrt[R^2 - (x - x0)^2], y0 + Sqrt[R^2 - (x - x0)^2]}, {z, z0 - Sqrt[R^2 - (x - x0)^2 - (y - y0)^2], z0 + Sqrt[R^2 - (x - x0)^2 - (y - y0)^2]}]; For a general function func = Function[{x,y,z},body] and a set of boundaries ...


3

If I understood correctly, you are trying to solve Ω in terms of a and the result of the integral P. I'd do something like this. f[a_?NumericQ, P_?NumericQ] := Module[{}, h[x_]:= 1/(1 + a x^2); FindRoot[ NIntegrate[x/(h[x] Exp[x/(h[x]) Ω] - 1),{x, 0, Infinity}] == P, {Ω, 2}]] // Quiet (*Maybe you would like to change the initial guess*) ...


3

I am a slightly confused by the equation for Fl[w] as it has a M term in it. However, since you are evaluating it with l = zero, that term drops out so I will ignore it in this answer. First step I think is good for this problem is to set h equal to a list: h = {0, 0.00015583, 0.0006215, ..., 0.00015583}; You can then view it by using the ListPlot ...


3

Alternatively, use FindRoot FindRoot[Integrate[ SquareWave[{0.2, 0}, ((x - 2.5)/10)], {x, 0 + a, 10 - a}] == 0.95, {a, .5}] {a -> 0.125}


3

Solve[{Integrate[ SquareWave[{2/10, 0}, ((x - 25/10)/10)], {x, a, 10 - a}, Assumptions -> 0 < a < 1] == 95/100, 0 <= a <= 1}, a, Reals] (* {{a -> 1/8}} *)


3

Integrate[Cos[a t], {t, 0, 2 Pi}] or the somewhat messy: Integrate[ Simplify[Re[ExpToTrig[Exp[I a t]]], Assumptions -> {a \[Element] Reals, t \[Element] Reals}], {t, 0, 2 Pi}] =>Sin[2 a \[Pi]]/a


3

According to your statement, I think what you need is just 4th-order Runge-Kutta method, and a completely self-made implementation of 4th-order Runge-Kutta method isn't necessary, then the answer from J.M. has shown you the optimal direction: (* Unchanged part omitted. *) ClassicalRungeKuttaCoefficients[4, prec_] :=With[{amat = {{1/2}, {0, 1/2}, {0, 0, ...


3

Here is a rigorous way to deal with the integration problem, making use only of the assumption that the integral is convergent so that we can exchange the integration and the series expansion for the Coulomb function: f[r_] := r^n E^(-r (1 + μ)) E^(-I k r) Hypergeometric1F1[I/k + 1, 2, 2 I k r]; g = f[r] /. {n -> 0, μ -> 0} (* ==> E^(-r - I ...


2

Define arg = r^n Exp[-r (1 + mu + I k)] Hypergeometric1F1[1 + I/k, 2, 2 I k r] Then, performing the inner integral in the Question, complete with Assumptions, Integrate[arg, {r, 0, Infinity}, Assumptions -> {k > 0, mu ∈ Reals, n ∈ Integers, n >= 0}] yields a ConditionalExpression with highly restrictive conditions, n < 1 && mu == ...


2

In Mathematica 10 I can evaluate this directly, without any intermediate steps. With[{α1 = 1.4, α2 = 0.8, x0 = 8, y0 = 1}, Integrate[ Piecewise[{{Exp[-y x^α1], x <= x0}, {Exp[-x0^(α1 - α2) y x^α2], x > x0}}], {x, 0, Infinity}, {y, y0, Infinity}, PrincipalValue -> True]] (* ∞ *)


2

Translating what you have: h[f_, t_] := t*Sinc[Pi f t]^2; t = 1.127*10^(-7); val = 10^6; NIntegrate[h[f, t], {f, (# - 0.5)*val, (# + 0.5)*val}] & /@ Range[20] But I think it is better that you integrate symbolically the sinc^2 function and just evaluate it for different limits. ref: comment. To do it symbolically Clear[h, f, t] h[f_, t_] := ...


2

Trace[Integrate[ Integrate[ Integrate[ E^(-v1 - v2 - v3) (v1 + v2 + v3)/3, {v3, 2 v1 - 5/2 v2, v2}], {v2, 4 v1/7, 5 v1/7}], {v1, 0, Infinity}]] Check one line before the result. I think this is what you want.


1

Try this exponential derivative operator: expD[f_, x_] := Module[{x0}, Sum[SeriesCoefficient[f, {x, x0, i}], {i, 0, \[Infinity]}] /. {x0 -> x} ] Examples: expD[x^2, x] (* (1 + x)^2 *) expD[Sin[x], x] (* Sin[1 + x] *) expD[Exp[x], x] (* Exp[1 + x] *)


1

I believe it's a bug, integrating to Infinity yields the correct result of 1.: Integrate[f[x], {x, Exp[x0], Infinity}] (* 1. *) Also, I think it's also a part of the possible issues for definite integrals, listed in the Integrate: eq = Integrate[f[x], x]; (eq /. {x -> 10}) - (eq /. {x -> Exp[x0]}) (* 0.992038 *)


1

func[t_, v_] := With[{s = Length[v]/2}, 2 Total@MapIndexed[#1 Cos[First@#2 t] &, Reverse[v[[1 ;; s - 1]]]] + v[[s + 1]]] Test: h = {2, 4, 10, 5, 12, 34, 12, 11}; Integrate[func[t, h]^2, {t, 0.234, 0.432}] yields: 305.526 Adjust as desired for non-even list length


1

h = {5, 7, 8, 15, 11, 17, 20, 20, 5, 3}; (*put your vector here*) n = Length[h] ;(*length of the vector, Even number*) F[x_] = h[[n/2 + 1]] + 2 Sum[h[[n/2 - l]] Cos[x l], {l, 1, n/2 - 1}]; NIntegrate[F[x]^2, {x, 0.234, 0.432}]


1

is this what you are looking for? h = {2, 4, 10, 5, 12, 34, 12, 11}; n = Length[h]; f[x_?NumericQ] := h[[n/2 + 1]] + 2 NSum[ h[[n/2 - i]] Cos[x*i], {i, 1, n/2 - 1}] NIntegrate[f[x]^2, {x, 0.234, 0.432}]


1

Something like this?: rect4[f_, a_, b_, n_] := With[{ex = Integrate[f[y], {y, a, b}], r = Range[0, n]}, With[{h = (b - a)/2.^r}, {r, #, {"/"}~Join~Ratios@#}\[Transpose] &@ Abs[ex - (b - a) Mean /@ f /@ Range[a, b - h, h]]]] MatrixForm@rect4[#^2 &, -1, 1, 6]


1

In my opinion, WhenEvent is still a wild beast in Mathematica, actually the only example for handling PDE with WhenEvent in the document only sets a "StopIntegration" event. Indeed, WhenEvent is able to do more, but quite tricky, see this post for example. For your problem, I think using Piecewise is a possible solution: T = 1; pde = D[f[t, x], {t, 1}] + ...


1

You can also use Solve Solve[Integrate[ (x^2 - .0015 x^4)/D[(x^2 - .0015 x^4), x], {x, 1.414, v}] == 50, v, Reals][[1]] // Quiet {v -> 12.9905}


1

s[v_?NumericQ] := NIntegrate[(x^2 - .0015 x^4)/D[(x^2 - .0015 x^4), x], {x, 1.414, v}] FindRoot[s[v] == 50, {v, 11}] (* {v -> 12.9905} *)


1

I think it just does not converge. In general high dimensional (>4) integral always converge fastest with monte carlo method. k = 0; Dynamic[k] NIntegrate[ Exp[-(T - tau)*(lambda1^2 + lambda2^2)^3]* Cos[(X - zeta1)*lambda1 + (Y - zeta2)* lambda2]*(D[Exp[-zeta1^2 - zeta2^2 - tau^2], {zeta1, 2}] + D[Exp[-zeta2^2 - zeta1^2 - tau^2], {zeta2, ...


1

Some issues one can spot: Some dependent variables are functions of M and R, some of n and R. While M and n appear as independent variables in the equations, for example, M[1][n, R] and n[1][M, R], they are not listed as integration variables. You have initial conditions for M[0] and n[0] but no corresponding differential equation. M and n appear both ...



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