在Mathematica 8中使用具有简单相等性的约束时,最小化不起作用.例如
FindMinimum[{x^2 + y^2, y == 1}, {x, y}]
Run Code Online (Sandbox Code Playgroud)
在Mathematica 6中工作正常,但在版本8中出错.任何人都可以确认(或解释)这个吗?看起来像使用约束修复其中一个参数会使版本8 xy==1变得混乱.放置就可以了,也就是任何不等式.
有什么简单的解决方法吗?我试过改变Method,没有运气.我想将所有参数保留在参数列表中,但是使用简单约束来保留其中一些参数,而不是从列表中删除参数名称.我在版本6中有一个工作代码,它在8中不再起作用了.
在Minimize[expr,{x1,x2,...}]为Mathematica安装CUDA模块后,Mathematica(如)中的内置函数是否可能通过CUDA开始工作?
我正在尝试访问GraphMathematica 8中对象内的信息.出于某种原因,该Part命令似乎不起作用.
myGraph 是我想要访问的对象.
下面的第一行显示myGraph.其他人则用来检查它.
myGraph
myGraph // FullForm
myGraph // InputForm
myGraph // OutputForm
myGraph[[1]]
myGraph[[2]]
Run Code Online (Sandbox Code Playgroud)

为什么不myGraph[[1]]回来List[1,3,4,2,5] ?[我检查了2级以防万一Graph被一些隐形包装包裹起来. Level[myGraph,1],简单地回来{}.并FullForm[myGraph][[1]]返回图表本身的图片.
我必须忽略一些明显的东西.
编辑
这是我用来生成图表的代码.其中大部分与手头的问题无关.但至少你会使用我正在使用的相同代码.
ClearAll[edges, compatibleQ, adjacentCourses, g];
edges[w_, b_] :=
Most /@ Accumulate /@
Flatten[Permutations[#] & /@ IntegerPartitions[w, All, b], 1]
compatibleQ[j_, k_, edg_] :=
If[Intersection[edg[[j]], edg[[k]]] == {}, {j, k}, False]
adjacentCourses[edg_] :=
Module[{len = Length[edg]},
Cases[Flatten[Table[compatibleQ[j, k, edg], {j, len}, {k, j, len}],
1], …Run Code Online (Sandbox Code Playgroud) 知道如何让这个工作吗?
y = {}; Table[Button[x, AppendTo[y, Evaluate[x]]], {x, 5}]
Run Code Online (Sandbox Code Playgroud)
结果:单击[ 1],单击[ 2],获取{6,6}
我轻视实际的任务,但我们的目标是建立一个内部的按钮做什么Map或Table或ParallelTable.
请帮忙!
编辑想
出来...... Evaluate只在第一级工作.在这里,它太深了.所以我用过ReplaceRule:
Remove[sub]; y = {}; Table[Button[x, AppendTo[y, sub]] /. sub -> x, {x, 5}]
Run Code Online (Sandbox Code Playgroud) 我可以将Style应用于下面"Labeled"的输出吗?
Manipulate[\[Lambda],
Control@{{\[Lambda], 401,
Style[" \[Lambda]", Black, Bold, 24]},
Range[401, 570, 1],
ControlType -> Slider,
ControlPlacement -> Bottom,
Appearance -> "Labeled",
ImageSize -> 200}]
Run Code Online (Sandbox Code Playgroud)
这是滑块的右侧部分:

我用它来创建一个条形图:
BarChart[
Reverse@data,
BarOrigin -> Left,
ChartLabels ->
Placed[{Reverse@labels, Reverse@data}, {Before, After}],
ChartElementFunction -> "FadingRectangle"
]
Run Code Online (Sandbox Code Playgroud)
有了data = {7, 10, 0, 6, 0, 3, 5}这个

问题是某些数据值为0,BarChart甚至不会为它们添加标签.相反,它留下了一个开放空间.即使值为0,我怎样才能使它仍然添加标签?
这是Mathematica 8.
某些类型的对象在Mathematica中具有特殊的输入/输出格式.这包括Graphics光栅图像,以及Mathematica 8的图形(Graph[]).遗憾的是,大型图形可能需要很长时间才能实现可视化,这比我在交互式工作期间对其进行的大多数其他操作要长得多.
如何防止Graph[]StandardForm和TraditionalForm 中对象的自动布局,并将它们显示为例如-Graph-,最好保留输出的可解释性(可能使用Interpretation?).我认为这将涉及改变Format和/或MakeBoxes以某种方式,但我没有成功实现这一点.
我想以可逆的方式执行此操作,并且最好定义一个函数,该函数在应用于Graph对象(不同于GraphPlot非交互式对象)时将返回原始交互式图形显示.
在相关的说明中,有没有办法检索与某些符号关联的Format/MakeBoxes定义? FormatValues是一个相关的功能,但它是空的Graph.
示例会话:
In[1]:= Graph[{1->2, 2->3, 3->1}]
Out[1]= -Graph-
In[2]:= interactiveGraphPlot[%] (* note that % works *)
Out[2]= (the usual interactive graph plot should be shown here)
Run Code Online (Sandbox Code Playgroud) Mathematica文档说明:"三维图形中的文本放置在与指定的点{x,y,z}的投影相对应的位置.文本在所有其他对象的前面绘制".如何相对于图像大小定位文本?
这是如何在2D中完成的:
custumLabels = Graphics[{
Text[Style["A", Red, Bold, 18], ImageScaled[{0.025, .95}]],
Text[Style["B", Red, Bold, 18], ImageScaled[{0.95, .05}]]}
];
Framed[Show[
Plot[
Sin[x] Exp[x], {x, 0, 10},
Frame -> True,
PlotRangeClipping -> False,
FrameLabel -> {"x", "y"}
],
custumLabels
],
FrameMargins -> 0]
Run Code Online (Sandbox Code Playgroud)

只要PlotRangeClipping设置为,那些标签将始终出现在该位置False.问题是,如果我切换到,如何使这些标签出现在该特定位置Graphics3D.尝试简单一点.
Framed[Show[
Graphics3D[{Sphere[{0, 0, 0}, 1]}]
],
FrameMargins -> 0]
Run Code Online (Sandbox Code Playgroud) 尝试使用具有Beta边缘的内置copula分布(Clayton,Frank,Gumbel)创建两个相关随机变量之和的分位数表.尝试NProbability和FindRoot各种方法 - 不够快.我需要探索的copula-marginal组合的一个例子如下:
nProbClayton[t_?NumericQ, c_?NumericQ] :=
NProbability[ x + y <= t, {x, y} \[Distributed]
CopulaDistribution[{"Clayton", c}, {BetaDistribution[8, 2],
BetaDistribution[8, 2]}]]
Run Code Online (Sandbox Code Playgroud)
对于使用的数值概率的单一评估
nProbClayton[1.9, 1/10] // Timing // Quiet
Run Code Online (Sandbox Code Playgroud)
我明白了
{4.914, 0.939718}
Run Code Online (Sandbox Code Playgroud)
在Vista 64bit Core2 Duo T9600 2.80GHz机器上(MMA 8.0.4)
要获得总和的分位数,请使用
FindRoot[nProbClayton[q, 1/10] == 1/100, {q, 1, 0, 2}// Timing // Quiet
Run Code Online (Sandbox Code Playgroud)
用各种方法
( `Method -> Automatic`, `Method -> "Brent"`, `Method -> "Secant"` )
Run Code Online (Sandbox Code Playgroud)
花大约一分钟才能找到一个分位数:时间是
{48.781, {q -> 0.918646}}
{50.045, {q -> 0.918646}}
{65.396, {q -> 0.918646}}
Run Code Online (Sandbox Code Playgroud)
对于其他copula-marginal组合,时间稍微好一些. …
我想编译一个Mathematica模块,因为我追求速度.
testC = Compile[{{inputInt, _Integer}},
Module[{outputInt, bitShift = 5},
outputInt = BitShiftRight[inputInt, bitShift]
]
, CompilationTarget -> "C", RuntimeOptions -> "Speed"
, CompilationOptions -> {"ExpressionOptimization" -> True,
"InlineCompiledFunctions" -> True,
"InlineExternalDefinitions" -> True}
];
Run Code Online (Sandbox Code Playgroud)
我的实际功能更长,但结构非常简单,使用列表,只包含以下功能:Total,Table,BitAnd,If.所有编译和运行时选项在我的实际函数中都很有用(可能),而不是这一行提取.
我已经设定
SetSystemOptions ["CompileOptions" - >"CompileReportExternal" - > True];
确保我能看到发生了什么,并且
CompilePrint [TESTC]
给出以下结果
1 argument
3 Integer registers
Underflow checking off
Overflow checking off
Integer overflow checking off
RuntimeAttributes -> {}
I0 = A1
I1 = 5
Result = I2
1 I2 = MainEvaluate[ Hold[BitShiftRight][ I0, …Run Code Online (Sandbox Code Playgroud)