English 中文(简体)
数学 形式??
原标题:Mathematica CForm / FortranForm bug?

我正试图从数学中产生一个非常复杂的矩阵(在平原文本中为~1.3MB)用于一个档方案。 当我这样做时(通过<代码>Splice),如果给变数以数字数值时,所形成的矩阵就将减少2%。 这是一个问题,因为需要一种精确为零的遗传价值,而遗传器的构成需要准确无误。

在精准、正确变数、适当的分校法等问题上,我尽了一切通常的尽职守,最终要么无法应对如此庞大的矩阵表或数学图谱,从而提升了档期产出。

因此,我用数学向我赠送矩阵表,并尝试这样做。 这比它应该的东西少了约2%,更令人惊讶的是,它(在机器精准的情况下)与FortranForm矩阵一样。

是否有人与这种问题接触? 你们是否有什么想法可以造成这种情况? 我读到了25 000条数学公式化法,以图此。

EDIT:所涉矩阵是复杂的,而不是大的。 这只是6x6,但每个要素都是个别地非常粗略的,包括三角测量功能、标志以及各种根源和权力。

http://pastebin.com/tu7tEmJE rel=“nofollow”>。 参数值为:0 < lambda, kappa, Y*** < 1; 所有其他数值为100至1,000。

最佳回答

看一看对第一个要素的表述,这几乎是确定性的问题,因为精确的浮动点算法。 在我看来,似乎有两种办法试图解决这一问题。 首先是在《刑法》中更加精确。 也许你可以使用宏观前处理器(或只是找到和取代)来将《刑法》中的所有声明翻一番,翻一番。 视你们使用什么编辑,从64比特到80或128(除非你使用将长一倍作为标准双倍处理。 如果你担任C编纂者,你会利用我帮助研究你为走这条路需要做哪些改动。 归根结底,如果你需要把它传给数学或刚刚使用双倍的C方案,你可以翻一番。

此外,汇编者还可以有不同的浮动点模式。 检查方式是否准确、严格或迅速。 如果是快速的或快速的,那就有可能造成你的四舍五入。

The other route is to use Mathematica to rearrange the terms of each element to optimize for floating point accuracy. While in general (a*b)*c=(c*b)*a in the land of floating point arithmetic this isn t true. The best heuristic I have heard of is:

  1. Addition: add the terms from smallest to largest to minimize rounding errors
  2. Subtraction: avoid or delay subtracting values that are very close to each other in value so you maintain as many significant digits as possible
  3. Multiplication/Division: avoid/delay multiplying by very small numbers or dividing by very large numbers for reasons of significant digits again.

从实际来看,这意味着把这些表述考虑在内,是你的最佳用词,特别是有问题的用词。 如果1~=a2,则该表述(a1-a2)(b-d)的准确性/重要数字应当高于(a1-a2)*b-(a1-a2)的精度/小数,因为你的乘数较少。

问题回答

这可能是以下简单的事情: a 数学与数字评价相当不相同,例如,这两个用语

N[(10^18+100)-10^18]
N[10^18+100]-N[10^18]

产出不变

Out[3]= 100.
Out[4]= 128. 

With C or Fortran you don t get any babysitting and the expression would be evaluated as in the second line.
Maybe you could look at a single matrix entry and try to evaluate it in Mathematica as C/Fortran would, and see if this matches what you see?

EDIT:
It seems that a simple test for problems with intermediate precision is to use Compile which drops all precision checks, so that

In[10]:= Compile[{a,b},a+100-b][10^18,10^18]
Out[10]= 128.

您能否核实贵国矩阵的汇编版本是否同意C/Fortran?





相关问题
Solving vector equations in Mathematica

I m trying to figure out how to use Mathematica to solve systems of equations where some of the variables and coefficients are vectors. A simple example would be something like where I know A, V, and ...

Introspection of messages generated in Mathematica

Is there any way to get at the actual messages generated during the evaluation of an expression in Mathematica? Say I m numerically solving an ODE and it blows up, like so In[1] := sol = NDSolve[{x [...

Connecting points in Mathematica

I have a collection of points displayed in a graphic: alt text http://img69.imageshack.us/img69/874/plc1k1lrqynuyshgrdegvfy.jpg I d like to know if there is any command that will connect them ...

Mathematica, PDF Curves and Shading

I need to plot a normal distribution and then shade some specific region of it. Right now I m doing this by creating a plot of the distribution and overlaying it with a RegionPlot. This is pretty ...

Targeted Simplify in Mathematica

I generate very long and complex analytic expressions of the general form: (...something not so complex...)(...ditto...)(...ditto...)...lots... When I try to use Simplify, Mathematica grinds to a ...

热门标签