Highest voted questions tagged assumptions - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-11-12T21:46:14Z https://mathematica.stackexchange.com/feeds/tag?tagnames=assumptions&sort=votes https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/19833 33 Usage of Assuming for Integration TriSSSe https://mathematica.stackexchange.com/users/5891 2013-02-19T14:25:29Z 2018-03-09T22:26:45Z <p>For some reason, when I enter the following integration in Mathematica</p> <pre><code>Assuming[{k ∈ Integers}, Integrate[ Exp[ I k t], {t, -π, π}]] </code></pre> <p>the result turns out to be 0. However, clearly, if $k = 0$, the integral should evaluate to $2\pi$ instead. Can someone explain this behavior?</p> https://mathematica.stackexchange.com/q/43108 27 Are greek symbols causing different evaluation? Mike https://mathematica.stackexchange.com/users/12667 2014-02-28T08:19:37Z 2015-07-04T02:43:27Z <p>I've updated today to Mathematica 9.0.1.0 from version 8 and found something that absolutely confuses me.<br> Let us define a piecewise function: </p> <pre><code>gr[x_, v1_, v2_, v3_, v4_, v5_] = Piecewise[{{g, v1 &lt; x &lt; v1+v2}, {g, v1+v3 &lt; x &lt; v1+v2+v3}, {gs, v1+v2+v3+v4 &lt; x &lt; v1+v3+v2+v4+v5}}, 0] </code></pre> <p>and try integrating it with obvious assumptions:</p> <pre><code>Integrate[gr[x, a, b, c, d, e], {x, 0, END}, Assumptions -&gt; {0 &lt; a &lt; a+b &lt; a+c &lt; a+b+c &lt; a+b+c+d &lt; a+b+c+d+e &lt; END}] </code></pre> <p>This takes around 60 seconds and obviously results in <code>2 b g + e gs</code> (although it seems it was a lot faster in Mathematica 8, though it's not the point here). Now, if we do the very same integration, but with different symbols:</p> <pre><code>Integrate[gr[x, τ, δ, Δ, τs, δs], {x, 0, TR}, Assumptions -&gt; {0 &lt; τ &lt; τ+δ &lt; τ+Δ &lt; τ+δ+Δ &lt; τ+δ+Δ+τs &lt; τ+δ+Δ+τs+δs &lt; TR}] </code></pre> <p>All of a sudden this doesn't evaluate in 60 seconds, running till it pages all the memory available and crashing afterwads. Can anyone explain this?</p> https://mathematica.stackexchange.com/q/18238 26 An apparently "simple" limit? Kagaratsch https://mathematica.stackexchange.com/users/5517 2013-01-22T13:39:20Z 2018-06-20T14:17:44Z <p>Let $c$ and $h$ be real values. I was using <em>Mathematica</em> to compute the limit $(h \rightarrow \infty)$ of the following expression:</p> <p>$$\frac{\left(h^2 +c^2 h^2 + \sqrt{4 h^2+\left(h^2+c^2 h^2\right)^2}\right)^2}{4\left(h^2 + \frac{1}{4}\left(h^2 +c^2 h^2 + \sqrt{4 h^2+\left(h^2+c^2 h^2\right)^2}\right)^2\right)}\text{//FullSimplify}$$ which is equal to $$=\frac{2}{4+(1+c^2)^2 h^2 - (1+c^2)\sqrt{4h^2+(1+c^2)^2 h^4}}$$</p> <p>Just as the rough estimate anyone can make by counting powers of $h$ in the numerator and denominator predicts, the <em>Mathematica</em> function <code>Limit[f[h], h -&gt; ∞]</code> gives $1$ in the nonsimplified case and gives $0$ in the simplified case. </p> <p>Now, I am a little confused about whether the correct limit is $1$ or $0$ ? And is the function <code>Limit</code> supposed to work that way as to not being able to distinguish the correct result from the wrong one ?</p> <p>Here is the <em>Mathematica</em> code</p> <pre><code>a = (h^2 + c^2 h^2 + Sqrt[4 h^2 + (h^2 + c^2 h^2)^2])^2/( 4 (h^2 + 1/4 (h^2 + c^2 h^2 + Sqrt[4 h^2 + (h^2 + c^2 h^2)^2])^2)) // FullSimplify; Limit[a, h -&gt; Infinity] </code></pre> <p>as you know, you can add or remove the <code>//FullSimplify</code> at the end of the definition for $a$ to switch between the two cases.</p> <p><strong>UPDATE:</strong></p> <p>As mentioned in the comments below, I have reported this as a bug to Wolfram support. They wrote back, were very polite and thankful, mentioned that this issue has been forwarded to their developer team and recommended to use <code>Assumptions</code> in order to be sure that everything goes well and additionally even speed up the computation.</p> <p><strong>EDIT:</strong></p> <p>Fun fact - 5 years later, if I try to evaluate the above limit in Mathematica </p> <pre><code>$Version </code></pre> <blockquote> <p><code>"11.2.0 for Microsoft Windows (64-bit) (September 11, 2017)"</code></p> </blockquote> <p>I get exactly the same discrepancy in the two limits as described above. Which means, Wolfram has ignored this bug in the <code>Limit</code> routine in the meantime.</p> https://mathematica.stackexchange.com/q/4135 21 Why doesn't FullSimplify drop the Re function from an expression known to be real? Joe https://mathematica.stackexchange.com/users/253 2012-04-11T14:17:47Z 2018-03-21T13:59:09Z <p>For some reason Mathematica does not properly simplify this expression: </p> <pre><code>In:= FullSimplify[ArcTan[-Re[x + z], y], (x | y | z) \[Element] Reals] Out= ArcTan[-Re[x + z], y] </code></pre> <p>Obviously, if <code>x</code> and <code>z</code> are real, then so is <code>x+z</code>, so <code>Re[x + z]</code> should be replaced by <code>x + z</code>. Strangely enough, dropping any small part of the input fixes the problem, here are some examples.<br> No minus sign: </p> <pre><code>In:= FullSimplify[ ArcTan[Re[x + z], y], (x | y | z) \[Element] Reals] Out= ArcTan[x + z, y] </code></pre> <p>No <code>z</code>:</p> <pre><code>In:= FullSimplify[ArcTan[-Re[x], y], (x | y | z) \[Element] Reals] Out= ArcTan[-x, y] </code></pre> <p>No <code>y</code>:</p> <pre><code>In:= FullSimplify[ArcTan[-Re[x + z]], (x | y | z) \[Element] Reals] Out= -ArcTan[x + z] </code></pre> <p>Of course I can just drop the <code>Re</code> function manually, but this is just a small fragment of the actual expression I'm trying to simplify, and I would like to avoid going though the whole expression looking for this specific pattern.<br> Anyone knows how to fix this? Is this a bug or what? (I'm using version 8.0.4.0)</p> https://mathematica.stackexchange.com/q/6489 20 Optimization with assumptions Oleg https://mathematica.stackexchange.com/users/1420 2012-06-06T12:10:48Z 2014-12-03T16:39:11Z <p>I have the following problem, when I am trying to optimize function with pre-defined assumptions.</p> <p>I am using Mathematica 8 and I wrote the following simple code</p> <pre><code>$Assumptions = (m &gt; 0) Minimize[{x^m, x &gt;= 1}, x] </code></pre> <p>It is clear, that the answer is 1, since $x^m\ge 1$ if $x\ge 1$ for all positive $m$. However, Mathematica fails to calculate this simple problem.</p> <p>What do I do wrong? Should I use another function for minimization?</p> https://mathematica.stackexchange.com/q/57489 18 Why does Mathematica simplify $x/x\to1$? Ruslan https://mathematica.stackexchange.com/users/5208 2014-08-16T15:09:42Z 2014-08-16T18:41:52Z <p>If I enter <code>x/x</code>, I get <code>1</code>. Such behavior leads to this:</p> <pre><code>Simplify[D[Sqrt[x^2], x, x]] </code></pre> <blockquote> <p>0</p> </blockquote> <p>The same would be even if I use <code>Together</code> instead of <code>Simplify</code>.</p> <p>One could then think that $\sqrt{x^2}$ is doubly differentiable at least $\forall x\in\mathbb R$, but if we remove <code>Simplify</code> call, we would reveal that it's not:</p> <pre><code>D[Sqrt[x^2], x, x] </code></pre> <blockquote> <p>-(x^2/(x^2)^(3/2)) + 1/Sqrt[x^2]</p> </blockquote> <p>Even more ridiculous is this (which I guess is because <code>x/x</code> is simplified before feeding to <code>Assuming</code>):</p> <pre><code>Assuming[x == 0, x/x] </code></pre> <blockquote> <p>1</p> </blockquote> <p>Why does Mathematica assume $x\ne0$? Is there a way to make it not cancel out such terms?</p> https://mathematica.stackexchange.com/q/3509 15 Does $x>0$ imply that $x\in\mathbb{R}$? max https://mathematica.stackexchange.com/users/796 2012-03-26T08:43:07Z 2012-07-05T10:57:31Z <p>Let’s assume I input</p> <pre><code>Assuming[x &gt; 0, expression] </code></pre> <p>Is it assumed by <em>Mathematica</em> that $x$ is a real number? Or that the real part of $x$ is positive? Something else?</p> <p>A simple <em>Mathematica</em> illustration would be welcome.</p> https://mathematica.stackexchange.com/q/2404 15 How to specify assumptions before evaluation? Peeter Joot https://mathematica.stackexchange.com/users/10 2012-02-28T02:31:41Z 2012-08-14T19:07:51Z <p>If I request mathematica evaluate an integral for me, I'll often get a more general <code>ConditionalExpression</code> than I want. Example :</p> <pre><code>Clear[ii, u, z, l, jj] ii = Integrate[ 1 / Sqrt[z^2 + u^2], {z, -l, l}] </code></pre> <blockquote> <pre><code>ConditionalExpression[ -Log[-l + Sqrt[l^2 + u^2]] + Log[l + Sqrt[l^2 + u^2]], Re[u/l] != 0 || Im[u/l] &gt;= 1 || Im[u/l] &lt;= -1] </code></pre> </blockquote> <p>I can reduce this after the fact with something like:</p> <pre><code>jj = FullSimplify[ii, u &gt; 0 &amp;&amp; l &gt; 0 &amp;&amp; Element[ u | l, Reals] ] </code></pre> <blockquote> <pre><code>Log[(u^2 + 2 l (l + Sqrt[l^2 + u^2]))/u^2] </code></pre> </blockquote> <p>but I'd imagine it should often simplify the calculations if I could provide the assumptions up front, especially the obvious ones like restricting various variables to the domain of reals.</p> <p>Is there a way to do this?</p> https://mathematica.stackexchange.com/q/10133 15 How to make use of NumericQ[x] = True (and use it safely)? telefunkenvf14 https://mathematica.stackexchange.com/users/197 2012-09-02T17:05:34Z 2012-09-02T22:42:42Z <hr> <h2>Basic Issue:</h2> <p>I'm trying to understand the proper use of <code>NumericQ</code>'s "magical" capabilities. Please consider the examples below. Actual question and some links are at the very end.</p> <hr> <h2>Example 1:</h2> <p>Many of you are aware that <code>NumericQ</code> can be used as follows, without unprotecting:</p> <pre><code>In:= Remove[x, y]; NumericQ[x] = True; (*and apparently using TagSet instead of Set makes no difference because \ you can't direct, let alone see, where this type of info is stored \ anyways.*) </code></pre> <p>The following output is as expected:</p> <pre><code>In:= NumericQ[x] NumericQ[y] Out= True Out= False </code></pre> <p>Go ahead and make the following assignment:</p> <pre><code>In:= x = y Out= y </code></pre> <p>The following behavior is interesting, but quite reasonable. It seems logical that setting <code>x</code> to <code>y</code> would somehow globally overwrite the "magical" numeric property:</p> <pre><code>In:= NumericQ[x] NumericQ[y] Out= False Out= False </code></pre> <h3><em>Hmmm... #1</em></h3> <p>...Well, at least I thought it would have 'overwritten' the behavior!!</p> <pre><code>In:= (*Note: Could also use Clear[x] or ClearAll[x] *) x =. NumericQ[x] Out= True </code></pre> <hr> <h2>Example 2:</h2> <p>Now suppose we had made the assignment <code>x = y</code> <em>first</em> (before evaluating <code>NumericQ[x] = True</code>): </p> <pre><code>In:= Remove[x, y]; x = y Out= y </code></pre> <h3><em>Hmmm... #2</em></h3> <p>Now <em>Mathematica</em> has pushed the numerical property onto <code>y</code> as well.</p> <pre><code>In:= NumericQ[x] = True NumericQ[y] Out= True Out= True </code></pre> <hr> <hr> <h2>Question:</h2> <p>How can one put <code>NumericQ[x] = True</code> to good/powerful use---and just as importanltly, in light of the above examples, how can it be used safely? (i.e., Can this behavior be localized somehow? Used safely within a package?---intuition makes me wonder if the only way to isolate the behavior would be to store impacted symbols in a junk context or something.)</p> <strong>Links of Interest:</strong> <p>@Szabolcs 'Mathematica Tricks' page; scroll down about half way or search for <code>NumericQ</code>: <a href="http://web.ift.uib.no/~szhorvat/mmatricks.php">http://web.ift.uib.no/~szhorvat/mmatricks.php</a></p> <p>MathGroup Discussion: <a href="https://groups.google.com/forum/?fromgroups=#!topic/comp.soft-sys.math.mathematica/buxdxzwV4bY">https://groups.google.com/forum/?fromgroups=#!topic/comp.soft-sys.math.mathematica/buxdxzwV4bY</a></p> https://mathematica.stackexchange.com/q/78348 14 Defining the domain of positive real numbers Remi.b https://mathematica.stackexchange.com/users/13408 2015-03-27T00:25:38Z 2019-06-18T20:31:25Z <p>I am trying to solve an equation by assuming that all the variables are real and strictly positive. I can use the keyword <code>Reals</code> for the argument <code>dom</code> in the Solve function <code>Solve[expr,vars,dom]</code>. Is there an equivalent for strictly positive <code>Reals</code>? Something like <code>PosReals</code></p> https://mathematica.stackexchange.com/q/9340 13 Complex number operations: telling Mathematica variables are real Marco Espinoza https://mathematica.stackexchange.com/users/1993 2012-08-12T05:30:12Z 2018-01-19T06:52:15Z <p>I want to do <code>Conjugate[a + b*I]</code>, but when I do that, the solution is <code>Conjugate[a] - I*Conjugate[b]</code>; when for me, a and b are reals.</p> <p>I want to obtain the following expresion : <code>a-b*I</code></p> <p>The same problem exists with the function <code>Abs</code>.</p> https://mathematica.stackexchange.com/q/23080 12 Why does Integrate declare a convergent integral divergent? Davide https://mathematica.stackexchange.com/users/6842 2013-04-10T17:48:11Z 2015-06-03T23:13:49Z <p>When I try this command</p> <pre><code>Integrate[1/Sqrt[(s^2 - u)^2 - 1], {s, m, Infinity}, Assumptions -&gt; u &gt; 2 &amp;&amp; m &gt; 10] </code></pre> <p><em>Mathematica</em> declares that the integral does not converge on <code>{m, ∞}</code></p> <p>The integral, though, is clearly convergent, and <em>Mathematica</em> has no trouble evaluating it at any value of $u &gt; 1$. A command such as </p> <pre><code>Integrate[1/Sqrt[(s^2 - 20.1)^2 - 1], {s, m, Infinity}, Assumptions -&gt; m &gt; 10] </code></pre> <p>works fine.</p> https://mathematica.stackexchange.com/q/4327 12 Maximizing a function with assumptions Helium https://mathematica.stackexchange.com/users/573 2012-04-16T22:35:10Z 2016-12-27T17:29:57Z <p>Using </p> <pre><code>f[s_] := Log[(s/r)^α ((α - 2) n0 r^α + 2 π Pmax ρ r^2) /((α - 2) n0 s^α + 2 π Pmax ρ s^2)]/s </code></pre> <p>When I run the following line:</p> <pre><code>Assuming[ s &gt; r &amp;&amp; r &gt; 1 &amp;&amp; Pmax &gt; n0 &amp;&amp; n0 &gt; 0 &amp;&amp; ρ &gt; 1 &amp;&amp; α &gt; 2, Maximize[f[s],s]] </code></pre> <p>I get the following output:</p> <pre><code>Maximize[Log[((s/r)^α (n0 r^α (-2 + α) + 2 π Pmax r^2 ρ)) /(n0 s^α (-2 + α) + 2 π Pmax s^2 ρ)]/s, s] </code></pre> <p>Actually, Mathematica ignores the assumptions and outputs the function only. That is, nothing is done by Mathematica. I know that <code>Assuming[.]</code> works with <code>Refine</code>, <code>Simplify</code>, and <code>Integrate</code>. But, is there any way to use <code>Maximize</code> with assumptions? What do you think about the given function? Is it analytically solvable at all?</p> <p><strong>EDIT:</strong> Let <code>g[x]=n0 β + 2 π ρ Pmax x^(-β)</code>, where <code>β = α - 2</code>. We can rewrite <code>f[s]</code> as:</p> <pre><code>f[s_] := Log[g[r]/g[s]]/s </code></pre> <p>for <code>β&gt;0</code>. Therefore, the optimal point is found by maximizing <code>Log[(g[r]/g[s])^(1/s)]</code> or equivalently maximizing <code>(g[r]/g[s])^(1/s)</code>. Mathematica cannot solve the latter optimization problem as well. Even with some more simplification, <code>r=1</code> and <code>n0=1</code>, which results in the following problem, it cannot be solved:</p> <pre><code>Maximize[{((β + 2 π Pmax ρ)/(β + 2 π Pmax s^-β ρ))^(1/s), β &gt; 0, Pmax &gt; 1, ρ &gt; 1}, s] </code></pre> https://mathematica.stackexchange.com/q/123881 12 Assumption on the range of a function MaPo https://mathematica.stackexchange.com/users/41161 2016-08-14T10:54:07Z 2016-08-14T17:30:27Z <p>I'm using value-defined function as set of parameter, i.e.</p> <pre><code>f ===&gt; first parameter f ===&gt; second parameter f ===&gt; third parameter </code></pre> <p>etc. I would like to tell Mathematica that all these parameters are positive. I tried something like</p> <pre><code>FullSimplify[Abs[f],Assumptions-&gt; {f[x_]&gt;0}] </code></pre> <p>and I get</p> <pre><code>Abs[f] </code></pre> <p>instead of the desired</p> <pre><code>f </code></pre> <p>Of course here I posted just an example, the function I have to simplify in my case is much more complicated. How can I do?</p> https://mathematica.stackexchange.com/q/38632 12 Simplify and Sqrt, inconsistent behavior? pwl https://mathematica.stackexchange.com/users/11084 2013-12-10T22:00:48Z 2013-12-11T08:20:00Z <p>I have encountered some problems when using <code>Simplify</code> with expressions containing a square root and isolated a following test case</p> <pre><code>Simplify[x - #[y], x == #[y]] &amp; /@ {Sin, Sqrt, #^s &amp;, #^(3/2) &amp;} </code></pre> <p>with a result</p> <pre><code>{0, x - Sqrt[y], 0, x - y^(3/2)} </code></pre> <ol> <li>Why is <code>x-Sqrt[y]</code> not simplified to <code>0</code> as in the case of <code>x-Sin[y]</code>?</li> <li>What is the logic behind simplifying <code>x-y^s</code> to <code>0</code>, but keeping x-y^(3/2)?</li> <li><p>Why do all the above differences vanish when we replace <code>-</code> with <code>==</code>? In such case</p> <pre><code>Simplify[x == #[y], x == #[y]] &amp; /@ {Sin, Sqrt, #^s &amp;, #^(3/2) &amp;} </code></pre> <p>results in</p> <pre><code>{True, True, True, True} </code></pre></li> </ol> https://mathematica.stackexchange.com/q/118955 11 How to assume all variables in my code are reals user42459 https://mathematica.stackexchange.com/users/40641 2016-06-21T08:28:32Z 2016-06-21T13:33:07Z <p>I won't have any occasion to have any imaginary number in my code. If there are any, that is an error. </p> <p>So allowing the imaginary case simply hinders the equation manipulation and simplification.</p> <p>I simply want to assume that all variables in my code are reals.</p> <p>I know default <em>Mathematica</em> doesn't provide this feature.</p> <p>However, from this page</p> <p><a href="https://mathematica.stackexchange.com/questions/95958/how-to-tell-mathematica-that-the-argument-of-a-function-is-real">How to tell Mathematica that the argument of a function is real?</a></p> <p>I learned it's possible to code up a function that will make a certain pattern (? Though I don't understand his answer quite much) to assume reals.</p> <p>Then perhaps it's also possible to code up a function that assumes all variables in the code are reals. Is it?</p> https://mathematica.stackexchange.com/q/13275 11 What exactly does GenerateConditions do? Emerson https://mathematica.stackexchange.com/users/1258 2012-10-18T19:48:42Z 2015-08-16T19:42:01Z <p>Consider for example this strange behavior:</p> <pre><code>Integrate[1/x, {x, 0, Infinity}, GenerateConditions -&gt; False] (*0*) </code></pre> <p>I'd also like to know the difference between <code>GenerateConditions -&gt; Automatic</code> and <code>GenerateConditions -&gt; True</code>.</p> https://mathematica.stackexchange.com/q/27338 11 Keeping Integrate from making unnecessary assumptions user8153 https://mathematica.stackexchange.com/users/8153 2013-06-20T21:22:06Z 2013-06-21T12:04:21Z <p>I would like to evaluate the integral $\int_{-\infty}^\infty \mathrm{d}x \, \exp\left(- a x^2 - x^4\right)$ for any real value of $a$. <em>Mathematica</em> 8.0.4 gives the following result:</p> <pre><code>Integrate[Exp[- a x^2 - x^4], {x, -∞, ∞}, Assumptions -&gt; {a ∈ Reals}] </code></pre> <blockquote> <pre><code>ConditionalExpression[1/2 Sqrt[a] E^(a^2/8) BesselK[1/4, a^2/8], a &gt;= 0] </code></pre> </blockquote> <p>Can I keep <em>Mathematica</em> from restricting its answer to non-negative values of $a$, especially since it can do the integral also for negative values:</p> <pre><code>Integrate[Exp[- a x^2 - x^4], {x, -∞, ∞}, Assumptions -&gt; {a &lt; 0}] </code></pre> <blockquote> <pre><code>(Sqrt[-a] E^(a^2/8) π (BesselI[-(1/4), a^2/8] + BesselI[1/4, a^2/8]))/(2 Sqrt) </code></pre> </blockquote> <p>I can construct the solution for all real $a$ from these two restricted solutions using <code>Piecewise</code>, but I'd rather not do that.</p> https://mathematica.stackexchange.com/q/34124 11 Limit of sequence of functions behaving strange Isak Kupersmidt https://mathematica.stackexchange.com/users/10029 2013-10-16T11:59:32Z 2017-09-04T19:09:18Z <p>I'm trying to determine the limit of the sequence of functions </p> <p>$$f_n(x)=\left(\frac{1}{\pi}\arctan(n x) + 1/2\right)^n.$$</p> <p>I define</p> <pre><code>f[x_, n_] := (1/2 + ArcTan[n x]/Pi)^n </code></pre> <p>And enter</p> <pre><code>Limit[f[x, n], n -&gt; Infinity] </code></pre> <p>This gives the answer 0.</p> <p>If I instead enter </p> <pre><code>Assuming[x &gt; 0, Limit[f[x, n], n -&gt; Infinity]] </code></pre> <p>I get the answer $$e^{-\frac{1}{x\pi}}.$$</p> <p>While </p> <pre><code>Assuming[x &lt; 0, Limit[f[x, n], n -&gt; Infinity]] </code></pre> <p>gives the answer 0 again.</p> <p>Why does the normal Limit give the answer assuming that x&lt;0? Is this a bug, or have I missed something?</p> <p>Thanks in advance.</p> https://mathematica.stackexchange.com/q/38118 10 Reduce can't reduce an equation without appropriate assumptions expression https://mathematica.stackexchange.com/users/7339 2013-12-01T18:04:07Z 2013-12-08T12:00:48Z <p>When there are three unknowns (<code>x</code>, <code>y</code>, <code>z</code>), <em>Mathematica</em> can solve it:</p> <pre><code>Reduce[ Abs[x] + Abs[y] + Abs[z] == 1 &amp;&amp; z != 0, {x, y, z}, Reals, Backsubstitution -&gt; True] </code></pre> <p>for four variables (<code>x</code>, <code>y</code>, <code>z</code>, <code>t</code>), <em>Mathematica</em> can't return a result in reasonable time:</p> <pre><code>Reduce[ Abs[x] + Abs[y] + Abs[z] + Abs[t] == 1 &amp;&amp; t != 0, {x, y, z, t}, Reals, Backsubstitution -&gt; True] </code></pre> <p><em>Maple</em> can solve this quickly: </p> <p><img src="https://i.stack.imgur.com/GCcZk.png" alt="enter image description here"></p> <p>Is it possible to solve this with <em>Mathematica</em>?</p> https://mathematica.stackexchange.com/q/133052 10 What assumptions do I need to make Mathematica integrate a function? user45146 https://mathematica.stackexchange.com/users/45146 2016-12-08T06:14:36Z 2016-12-16T23:08:20Z <p>When I feed <em>Mathematica</em> the following integral:</p> <pre><code>Integrate[Sqrt[(A - x) (B - x)/x], {x, 0, B}] </code></pre> <p>it spits it back out without evaluating it. However, it can evaluate the integral</p> <pre><code>Integrate[Sqrt[(2 - x) (1 - x)/x], {x, 0, 1}] </code></pre> <p>just fine. From reading other questions, I think the problem is that I need to add more assumptions. I tried every assumption I know about:</p> <pre><code>Integrate[Sqrt[(A - x) (B - x)/x], {x, 0, B}, Assumptions -&gt; {A &gt; 0, B &gt; 0, A &gt; B, x ∈ Reals, A ∈ Reals, B ∈ Reals}] </code></pre> <p>but <em>Mathematica</em> still won't do the integral. I know it has to be able to do the integral, since it can do it for definite values of $A$ and $B$ just fine! What other assumptions do I need to add to make it work?</p> https://mathematica.stackexchange.com/q/192076 10 Linearity Assumption [duplicate] Mirko Aveta https://mathematica.stackexchange.com/users/36621 2019-02-23T15:04:26Z 2019-02-23T15:24:36Z <div class="question-status question-originals-of-duplicate"> <p>This question already has an answer here:</p> <ul> <li> <a href="/questions/192073/neglect-higher-order-derivatives-in-expression" dir="ltr">Neglect higher order derivatives in expression</a> <span class="question-originals-answer-count"> 1 answer </span> </li> </ul> </div> <p>I'd like to define a set of variables of this sort:</p> <pre><code>{K1[t],K2[t],...} </code></pre> <p>Adding a general assumption: all such variables are linear. I'd like to do this to avoid Mathematica having to show me higher order derivatives of these functions in my solution.</p> https://mathematica.stackexchange.com/q/11195 10 Is my expression too complicated for FullSimplify or am I doing something wrong? intermath https://mathematica.stackexchange.com/users/2450 2012-09-27T23:54:56Z 2012-09-29T02:26:59Z <p>I have a messily defined function $v(h, w)$ with $h, w \in \mathbb{R}$ and with a removable singularity at $h=1/2$, and I am trying to prove some of its properties using Mathematica. In particular I want to prove that $v(h,w) \in \mathbb{R}$, as opposed to possibly having nonzero imaginary part, and I want to prove that $v(h,w) = v(1-h, -w)$. I am defining the function in Mathematica as follows:</p> <pre><code>a[h_] = h / (2*h - 1) q[h_, w_] = Sqrt[2*h - 1] * Sqrt[2*w] v[h_, w_] = Exp[-w]*(2/Sqrt[Pi])*q[h,w]*Exp[(q[h,w]*a[h])^2] / ( Erfi[q[h,w]*a[h]] + Erfi[q[h,w]*(1 - a[h])] ) </code></pre> <p>I apologize for its messiness. My initial hope was that Mathematica would tell me that this is just a well known special function with known properties which I could cite. My next hope was that I could at least use applications of FullSimplify with Assumptions to prove the properties. But I have not been successful at either approach.</p> <p>To make my question more concrete, I am wondering why Mathematica does not simplify the following expression to True:</p> <pre><code>FullSimplify[ v[h, w] == v[1 - h, -w], Element[{w,h}, Reals] &amp;&amp; h != 1/2] </code></pre> <p>One possibility is that I am wrong about the math. I've tried to rule this out by using Mathematica to prove special cases like the following, where I've also tried other values of $h$ besides $1/5$.</p> <pre><code>FullSimplify[ v[1/5, w] / v[1 - 1/5, -w] ] FullSimplify[ v[1/5, w] - v[1 - 1/5, -w] ] FullSimplify[ v[1/5, w] == v[1 - 1/5, -w] ] </code></pre> <p>Another possibility is that it is too hard for Mathematica. But I think the most likely explanation is that I'm using Mathematica wrong because I'm a newbie.</p> <hr> <p><strong>Update</strong>:<br> Inspired by @rcollyer's answer I took out a pencil and paper and figured out how to write this function as the reciprocal of a series that satisfies the properties by construction:</p> <pre><code>fterm[h_, w_, k_] = (((-4*w)^k) / (2*k+1)!!) * (h / (2*h-1)) * Exp[w]*(h^2 / (2*h-1))^k f[h_, w_] = Sum[fterm[h, w, k] + fterm[1-h, -w, k], {k, 0, Infinity}] </code></pre> <p>Mathematica is still unable to directly verify that $f(h,w) = f(1-h,-w)$ on the appropriate domain, but $1/f(h,w)$ compares True to the original function $v(h,w)$. As a side note, I had hoped that in the process of verifying these properties I would find a formula that gets rid of the computational difficulty associated with the removable singularity at $h=1/2$ for free, but this did not happen.</p> https://mathematica.stackexchange.com/q/94983 10 Is it possible to add some pattern to $Assumptions Sungmin https://mathematica.stackexchange.com/users/10763 2015-09-18T21:33:20Z 2015-09-19T01:32:30Z <p>I apologize if it is a too elementary question but I could not find the appropriate documentation so far. </p> <p>My goal is simple. I would like to add some assumptions that are defined in terms of patterns rather than symbols. For example, I would like to something like this </p> <pre><code>$Assumptions = { a[ ___ ] &gt; 0 }; </code></pre> <p>In my ideal world, this should set every expression with the <code>Head</code> <code>a</code> should be considered positive. Is it possible in Mathematica?</p> <p>EDIT: Thanks. Following the first comment and the first answer, I did the following experiment. I still got puzzled about the result. Maybe it is just because of the intricate interaction between <code>Integrate</code> and <code>$Assumptions</code>.</p> <pre><code>$Assumptions = {A[___] &gt; 0, B &gt; 0}; Integrate[ Exp[ - A[x] t] , {t, 0, \[Infinity]}] Integrate[ Exp[ - B t] , {t, 0, \[Infinity]}] (* output *) ConditionalExpression[1/A[x], Re[A[x]] &gt; 0] 1/B </code></pre> <p>In this example, <code>Integrate</code> does not make use of the fact <code>A[___]&gt;0</code>.</p> https://mathematica.stackexchange.com/q/6397 9 Is it possible to set a variable as a positive one in the whole notebook? Öskå https://mathematica.stackexchange.com/users/1356 2012-06-04T11:00:54Z 2012-06-04T11:23:17Z <p>I'm having issues during integration due to the fact that <em>Mathematica</em> doesn't know if an undefined variable is positive or not (it gives me complexes which bothers me in the end).</p> <p>For example I do this: </p> <pre><code>yy[x_, t_] = aa[t]*(Cos[0.1*x]-Cosh[0.1 x]-Sin[0.1 x]+Sinh[0.1 x]) Integrate[D[yy[x, t], t]^2, {x, 0, 18}] </code></pre> <p>gives me: </p> <blockquote> <p><code>(10.1601 + 0.I) aa'[t]²</code></p> </blockquote> <p>while the <code>0.I</code> shouldn't be here. By using:</p> <pre><code>Integrate[D[yy[x, t], t]^2, {x, 0, 18}, Assumptions -&gt; aa[t] &gt; 0] </code></pre> <p>I get rid of the imaginary part but this has to be done cell by cell.</p> <p>Then comes my questions, is it possible to define, in that case, <code>aa[t]</code> as a posivite variable in the whole notebook and not cell by cell?<br> Note that in this expample the <code>I</code> is not bothering at all, but with concrete numbers it messes everything up, even by using <code>Chop</code>.</p> https://mathematica.stackexchange.com/q/135190 9 Reduce not making full use of list of assumptions? Bobson Dugnutt https://mathematica.stackexchange.com/users/38017 2017-01-11T18:04:37Z 2017-01-11T20:21:23Z <p>I have the following inequality, with conditions: </p> <pre><code>Reduce[ {-(a + b) &gt; Sqrt[(a + b)^2 - 4 (a b - c d)], Element[{a, b, c, d}, Reals], a + b &lt; 0, a b - c d &gt; 0, (a + b)^2 &gt; 4 (a b - c d)}, {a, b} ] </code></pre> <p>However, the very first line of the output gives <code>c ∈ Reals &amp;&amp; ...</code>. In itself, it is rather inconsequential, but it made me wonder if Mathematica doesn't make full use of the given conditions? Another pointer in this direction is that if I remove all the conditions, the output is actually slightly shorter, which doesn't make sense to me. </p> <p>What is going on here? Thanks. </p> https://mathematica.stackexchange.com/q/99037 9 Problem with Identifying Complex Components jpdomann https://mathematica.stackexchange.com/users/35456 2015-11-10T05:37:04Z 2015-11-10T10:43:10Z <p>I am trying to isolate out the real and complex terms in a fairly large expression. During the process, I have made several assumptions that last throughout the entire process. </p> <pre><code>$Assumptions = Element[{x,y},Reals] &amp;&amp; {x,y}&gt;0 </code></pre> <p>When I try separating the real and complex parts, the <code>Re</code> and <code>Im</code> functions have trouble with terms where variables appear in the denominator. For example </p> <pre><code>Im[1/(x^2 + 4 y^2)^(9/2)] //Simplify = Im[1/(x^2 + 4 y^2)^(9/2)] </code></pre> <p>Even though all the terms are real and positive, meaning there should be no complex component, and the expression should be zero</p> <p>I have checked, and if the denominator does not involve two or more terms, <code>Im</code> does work successfully. For example </p> <pre><code>Im[1/(x^2)^(9/2) ] //Simplify = 0 Im[1/(4 y^2)^(9/2)] //Simplify = 0 </code></pre> <p>Can someone please comment on if this is a bug in the version I have, or am I doing something incorrect here? A mwe is provided below. For reference, I am using version 10.0.0.0</p> <p>-Thanks</p> <pre><code>In:=$Assumptions = Element[{x, y}, Reals] &amp;&amp; {x, y} &gt; 0 ; Simplify[Im[1/(x^2 + 4*y^2)^(9/2)]] Simplify[Im[1/(x^2)^(9/2)]] Simplify[Im[1/(y^2)^(9/2)]] Out= Im[1/(x^2+4 y^2)^(9/2)] Out= 0 Out= 0 </code></pre> <h2>Edit</h2> <p>If I modify the assumptions to define each one separately, the code runs fine. e.g</p> <pre><code>$Assumptions = Element[x, Reals] &amp;&amp; Element[y, Reals] &amp;&amp; x &gt; 0 &amp;&amp; y &gt; 0 ; </code></pre> <p>In my main program, I have a large number of variables that are both real and positive, is there a way to assign these all at once, or do I need to do each one separately?</p> https://mathematica.stackexchange.com/q/47548 9 Simplify with Assumptions Sqrt[(expr)^2] tchronis https://mathematica.stackexchange.com/users/7966 2014-05-09T13:45:50Z 2016-10-12T02:29:26Z <p>While trying to simplify expressions in the form <code>Sqrt[(expr)^2]</code> when <code>expr&gt;0</code> I noticed a peculiar behavior that was not resolved with code from <a href="https://mathematica.stackexchange.com/a/31486/7966">this Q&amp;A</a>.</p> <pre><code>Simplify[Sqrt[(x - y + a b c)^2], x - y + a b c &gt; 0] </code></pre> <blockquote> <pre><code>Abs[a b c + x - y] </code></pre> </blockquote> <p>When I remove any of the <code>a</code>, <code>b</code>, <code>c</code>, <code>x</code> or <code>y</code> it returns the result without the <code>Abs</code>:</p> <pre><code>Simplify[Sqrt[(x - y + b c)^2], x - y + b c &gt; 0] </code></pre> <blockquote> <pre><code>b d + x - y </code></pre> </blockquote> <p>I loose faith when I meet such behavior with Mathematica :-(</p> <p>Even though </p> <pre><code>Simplify[Sqrt[expr^2], expr &gt; 0] /. expr -&gt; (x - y + a b c) </code></pre> <p>does fix the first issue how could I simplify this:</p> <pre><code>Simplify[Sqrt[(x - y + a ^2 b^2 c^2)^2], x &gt; y] </code></pre> <p>Anyway, can anybody explain why this happens and propose a way to fix it for general expressions?</p> https://mathematica.stackexchange.com/q/6182 9 Assumptions on unknown functions Lemming https://mathematica.stackexchange.com/users/1347 2012-05-29T15:27:53Z 2013-01-15T11:08:43Z <p>I'm trying to do analytic calculations in a quantum mechanic harmonic oscillator basis. Specifically I want to be able to evaluate functions of the many particle density.</p> <p>I define the following functions: [<em>definitions</em>]</p> <pre><code>(* Harmonic Oscillator Eigenstate *) basis[i_, z_] = Pi^(-1/4)/Sqrt[2^i Factorial[i]] Exp[-z^2/2] HermiteH[i, z]; (* Orbital *) orb[i_, z_] = Sum[c[i, k] basis[k, z], {k, 0, t}]; (* Particle density of one orbital *) orbitaldens[i_, z_] = Conjugate[orb[i, z]] psi[i, z]; (* Total density *) dens[z_] = Sum[a[i] orbitaldens[i, z], {i, 1, n}]; </code></pre> <p>To help Mathematica I define some assumptions beforehand: [<em>assumptions</em>]</p> <pre><code>$Assumptions = Element[z, Reals] &amp;&amp; (* Real-space coordinate is real *) Element[{n, t}, Integers] &amp;&amp; n &gt; 0 &amp;&amp; t &gt; 0 &amp;&amp; (* Just indices *) Element[c[i_, j_], Complexes] &amp;&amp; (* Complex state vector *) Element[a[i_], Reals]; (* Real filling factor *) </code></pre> <p>What is the correct way to define assumptions on an unknown function? Here <code>c[i_, j_]</code> should take integers <code>i</code>, and <code>j</code> and return a complex number. <code>a[i_]</code> on the other hand should take on integer <code>i</code> and return a positive real number.</p> <p>Unfortunately, the evaluation of the <em>definitons</em> takes very long if I include these <em>assumptions</em>. Without them the <em>definitions</em> block takes about a second to evaluate.</p> <p>However, I need those assumptions, so Mathematica can do useful simplifications. For example <code>Conjugate[orb[i,z]] orb[i,z]//FullSimplify</code> should simplify to <code>Abs[orb[i,z]]^2</code>. But the same should work, if I only apply the complex conjugation to <code>c[i,k]</code> inside <code>orb[i,z]</code>, because <code>basis[i,z]</code> is real. So far, this takes too long to evaluate.</p> <p>Is it possible to speed this whole thing up?</p> <p>Another problem I found is the codomain of the Factorial The following two expressions do not evaluate to True, neither to False. They just repeat the first parameter of <code>Refine</code>:</p> <pre><code>Refine[Element[Sqrt[Factorial[i]], Reals], Element[i, Integers] &amp;&amp; i &gt; 0] Refine[Factorial[i] &gt; 0, Element[i, Integers] &amp;&amp; i &gt; 0] </code></pre> <p>In words, the factorial of a positive integer is not necessarily positive.</p> <p>What is wrong there? I don't see how the factorial of a positive integer could become negative. (In symbolic maths)</p> https://mathematica.stackexchange.com/q/42114 9 When and why are Assuming and Assumptions not equivalent? [duplicate] Szabolcs https://mathematica.stackexchange.com/users/12 2014-02-11T13:58:25Z 2014-02-11T14:30:41Z <div class="question-status question-originals-of-duplicate"> <p>This question already has an answer here:</p> <ul> <li> <a href="/questions/19833/usage-of-assuming-for-integration" dir="ltr">Usage of Assuming for Integration</a> <span class="question-originals-answer-count"> 4 answers </span> </li> </ul> </div> <p>In <a href="https://mathematica.stackexchange.com/q/42109/12">this question</a> there's an example of an integral where using <code>Assuming</code> and <code>Assumptions</code> give different results:</p> <pre><code>In:= Integrate[Cos[n x], {x, 0, Pi}, Assumptions -&gt; Element[n, Integers]] Out= Sin[n π]/n In:= Assuming[Element[n, Integers], Integrate[Cos[n x], {x, 0, Pi}]] Out= 0 In:= Integrate[Cos[n x], {x, 0, Pi}, Assumptions -&gt; Element[n, Integers]] Out= Sin[n π]/n </code></pre> <p>Now let's clear the system cache (or restart the kernel if you like) and try again, but now in a different order:</p> <pre><code>In:= ClearSystemCache[] (* fresh start! *) In:= Assuming[Element[n, Integers], Integrate[Cos[n x], {x, 0, Pi}]] Out= 0 In:= Integrate[Cos[n x], {x, 0, Pi}, Assumptions -&gt; Element[n, Integers]] Out= 0 </code></pre> <p>To make things even more weird, the results are affected by the order these two versions are evaluated (clearly due to caching). <code>In</code> and <code>In</code> are the same but they return different results.</p> <p>I always assumed that using <code>Assuming</code> or <code>Assumptions</code> with built-in functions should be equivalent. It seems this is not true. I can imagine that <code>Integrate</code> uses something internally (e.g. <code>Refine</code>) that is affected by the global <code>Assuming</code>, but not by <code>Assumptions</code>.</p> <p>Generally, when are <code>Assuming</code> and <code>Assumptions</code> not equivalent?</p> <p>Is the result I quoted above a bug?</p> <hr> <p><strong>EDIT:</strong> As Artes and Michael noted in the comments, this is explained by Daniel Lichtblau <a href="https://mathematica.stackexchange.com/a/19894/12">here</a>. My only remaining worry is that the results are cached and effectively depend on the order of evaluation.</p>