Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4041 > unrolled thread
| Started by | Sebastian Hofer <sebhofer@gmail.com> |
|---|---|
| First post | 2011-07-29 08:44 +0000 |
| Last post | 2011-08-03 11:06 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Indeterminate result (numerical problem) Sebastian Hofer <sebhofer@gmail.com> - 2011-07-29 08:44 +0000
Re: Indeterminate result (numerical problem) Gary Wardall <gwardall@gmail.com> - 2011-07-30 10:07 +0000
Integrate + Conjugate = Indeterminate Sebastian Hofer <sebhofer@gmail.com> - 2011-08-02 11:14 +0000
Re: Integrate + Conjugate = Indeterminate Daniel Lichtblau <danl@wolfram.com> - 2011-08-03 11:06 +0000
| From | Sebastian Hofer <sebhofer@gmail.com> |
|---|---|
| Date | 2011-07-29 08:44 +0000 |
| Subject | Indeterminate result (numerical problem) |
| Message-ID | <j0tru0$d4m$1@smc.vnet.net> |
I have a large symbolic expression which is a sum of a large number of fractions, which is the result of an integral. I can get numerical values by NIntegrate, but eventually the expression should go into a minimization problem, which would be much faster starting from an analytic expression. My troubles start even earlier though. When I try to evaluate the expression by
N[expr/.parameters]
I get Indeterminate. This is true independently of the precision given to N(machine or arbitrary precision) or the chosen parameters, which I initially chose to be rational numbers from an interval of about 1/10 to 10. Simplifying the symbolic expression is not possible due to its sheer size. Simplifying the separate terms and evaluating them gives me a result, but only if I set $MinPrecision=$MaxPrecision as in
In[466]:= Block[{prec=MachinePrecision,$MaxPrecision,$MinPrecision},$MaxPrecision=$MinPrecision=prec;N[slist,prec]//Total]
Out[466]= -0.0000554539 + 0.000957437 I
where slist contains the simplified and evaluated terms. If I work with arbitrary precision instead I get
In[462]:= Block[{prec=16,$MaxPrecision,$MinPrecision},$MaxPrecision=$MinPrecision=prec;N[slist,prec]//Total]
Out[462]= -0.00001695456281093148 + 0.0009204297860912486 I
The latter result coincides with what I obtain from NIntegrate, which I guess is correct. (Is this a valid assumption?)
However, for different values of prec I get very strange results:
prec=17,18,21: same as prec=16
prec=19: -0.001922263621488465141 - 0.003379886739497078367 I
prec: Indeterminate
prec=22: -0.0006868461930781501884710 - 0.0006068980872473164707112 I
...
What is the best way to approach this problem? How do I know which results I can trust? Is there a better approach to start with? All tips are highly welcome!
Sebastian
[toc] | [next] | [standalone]
| From | Gary Wardall <gwardall@gmail.com> |
|---|---|
| Date | 2011-07-30 10:07 +0000 |
| Message-ID | <j10l4q$otj$1@smc.vnet.net> |
| In reply to | #4041 |
On Jul 29, 3:44 am, Sebastian Hofer <sebho...@gmail.com> wrote:
> I have a large symbolic expression which is a sum of a large number of fractions, which is the result of an integral. I can get numerical values by NIntegrate, but eventually the expression should go into a minimization problem, which would be much faster starting from an analytic expression. My troubles start even earlier though. When I try to evaluate the expression by
>
> N[expr/.parameters]
>
> I get Indeterminate. This is true independently of the precision given to N(machine or arbitrary precision) or the chosen parameters, which I initially chose to be rational numbers from an interval of about 1/10 to 10. Simplifying the symbolic expression is not possible due to its sheer size. Simplifying the separate terms and evaluating them gives me a result, but only if I set $MinPrecision=$MaxPrecision as in
>
> In[466]:= Block[{prec=MachinePrecision,$MaxPrecision,$MinPrecision},$MaxPrecision=$MinPrecision=prec;N[slist,prec]//Total]
>
> Out[466]= -0.0000554539 + 0.000957437 I
>
> where slist contains the simplified and evaluated terms. If I work with arbitrary precision instead I get
>
> In[462]:= Block[{prec=16,$MaxPrecision,$MinPrecision},$MaxPrecision=$MinPrecision=prec;N[slist,prec]//Total]
>
> Out[462]= -0.00001695456281093148 + 0.0009204297860912486 I
>
> The latter result coincides with what I obtain from NIntegrate, which I guess is correct. (Is this a valid assumption?)
> However, for different values of prec I get very strange results:
> prec=17,18,21: same as prec=16
> prec=19: -0.001922263621488465141 - 0.003379886739497078367 I
> prec: Indeterminate
> prec=22: -0.0006868461930781501884710 - 0.0006068980872473164707112 I
> ...
>
> What is the best way to approach this problem? How do I know which results I can trust? Is there a better approach to start with? All tips are highly welcome!
> Sebastian
Sebastian,
Without seeing the symbolic expressions you started with it's
difficult to fully understand the problem.
Gary
[toc] | [prev] | [next] | [standalone]
| From | Sebastian Hofer <sebhofer@gmail.com> |
|---|---|
| Date | 2011-08-02 11:14 +0000 |
| Subject | Integrate + Conjugate = Indeterminate |
| Message-ID | <j18m61$sn6$1@smc.vnet.net> |
| In reply to | #4041 |
I know that my question was originally posed in a very vague way, which was partly due to me having no idea where my problems came from. After more analysis of the involved expressions, I managed to get them into a form which can be evaluated numerically without getting Indeterminate values. What I essentially did was to use a combination of iterated Expands and replacement rules like
Expand[#] /. Power[E, x_] :> Power[E, FullSimplify@Expand@x]
(the expressions involve several similar exponentials which are multiplied and added...). Also, as the whole expression is the result of an integral, I separated the sub-expression which needed to be integrated before the integration and put everything back together afterwards.
Also, I was bitten by (let's call it) a very peculiar "feature" of Mathematica's handling of Conjugate:
In[25]:= Integrate[
Exp[(Sqrt[a + I b] - Conjugate[Sqrt[a - I b]]) x], {x, x0, x1},
Assumptions -> a > 0 && b > 0]
Out[25]= (-E^(
x0 (Sqrt[a + I b] - Conjugate[Sqrt[a - I b]])) + E^(
x1 (Sqrt[a + I b] - Conjugate[Sqrt[a - I b]])))/(Sqrt[a + I b] -
Conjugate[Sqrt[a - I b]])
In[23]:= Out[18] /. {a -> 1, b -> 2} // N
During evaluation of (Local 2) In[23]:= Power::infy: Infinite expression 1/(0. +0. I)
encountered. >>
During evaluation of (Local 2) In[23]:= Power::infy: Infinite expression 1/(0. +0. I)^1.
encountered. >>
During evaluation of (Local 2) In[23]:= Infinity::indet: Indeterminate expression (0. +0. I) ComplexInfinity
encountered. >>
Out[23]= Indeterminate
Of course this holds for all a,b. Is there any logical explanation for this? Or better: Is there a way to get around it? This problem is probably known to many of you, but it was new to me and I would think it is a bug...
Sebastian
[toc] | [prev] | [next] | [standalone]
| From | Daniel Lichtblau <danl@wolfram.com> |
|---|---|
| Date | 2011-08-03 11:06 +0000 |
| Subject | Re: Integrate + Conjugate = Indeterminate |
| Message-ID | <j1ba4j$aj0$1@smc.vnet.net> |
| In reply to | #4041 |
On 08/02/2011 06:12 AM, Sebastian Hofer wrote:
> I know that my question was originally posed in a very vague way, which was partly due to me having no idea where my problems came from. After more analysis of the involved expressions, I managed to get them into a form which can be evaluated numerically without getting Indeterminate values. What I essentially did was to use a combination of iterated Expands and replacement rules like
>
> Expand[#] /. Power[E, x_] :> Power[E, FullSimplify@Expand@x]
>
> (the expressions involve several similar exponentials which are multiplied and added...). Also, as the whole expression is the result of an integral, I separated the sub-expression which needed to be integrated before the integration and put everything back together afterwards.
>
> Also, I was bitten by (let's call it) a very peculiar "feature" of Mathematica's handling of Conjugate:
>
> In[25]:= Integrate[
> Exp[(Sqrt[a + I b] - Conjugate[Sqrt[a - I b]]) x], {x, x0, x1},
> Assumptions -> a> 0&& b> 0]
>
> Out[25]= (-E^(
> x0 (Sqrt[a + I b] - Conjugate[Sqrt[a - I b]])) + E^(
> x1 (Sqrt[a + I b] - Conjugate[Sqrt[a - I b]])))/(Sqrt[a + I b] -
> Conjugate[Sqrt[a - I b]])
>
> In[23]:= Out[18] /. {a -> 1, b -> 2} // N
>
> During evaluation of (Local 2) In[23]:= Power::infy: Infinite expression 1/(0. +0. I)
> encountered.>>
>
> During evaluation of (Local 2) In[23]:= Power::infy: Infinite expression 1/(0. +0. I)^1.
> encountered.>>
>
> During evaluation of (Local 2) In[23]:= Infinity::indet: Indeterminate expression (0. +0. I) ComplexInfinity
> encountered.>>
>
> Out[23]= Indeterminate
>
> Of course this holds for all a,b. Is there any logical explanation for this? Or better: Is there a way to get around it? This problem is probably known to many of you, but it was new to me and I would think it is a bug...
>
> Sebastian
The reason behind it is that Mathematica fails to recognize that (Sqrt[a
+ I b] - Conjugate[Sqrt[a - I b]]) is zero when a,b>0.
Daniel Lichtblau
Wolfram Research
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web