SAGE中的函数solve()返回我求解方程式的变量的符号值.例如:
sage: s=solve(eqn,y)
sage: s
[y == -1/2*(sqrt(-596*x^8 - 168*x^7 - 67*x^6 + 240*x^5 + 144*x^4 - 60*x - 4) + 8*x^4 + 11*x^3 + 12*x^2)/(15*x + 1), y == 1/2*(sqrt(-596*x^8 - 168*x^7 - 67*x^6 + 240*x^5 + 144*x^4 - 60*x - 4) - 8*x^4 - 11*x^3 - 12*x^2)/(15*x + 1)]
Run Code Online (Sandbox Code Playgroud)
我的问题是我需要在其他计算中使用为y获得的值,但我不能将这些值分配给任何其他变量.有人可以帮我这个吗?
我试图以四倍精度对齐矩阵,并采用它们的对数.有没有一种语言可以使用内置函数实现这一目的?
注意,标签中的语言/包不足,存在以下缺陷:
Matlab:不支持四精度.
Python/NumPy/SciPy:带有dtype float128的矩阵在float64中产生特征向量.
Sage:通过GP/PARI接口会产生神秘的错误消息.
有没有人执行对角化和矩阵对数到四倍精度,如果有,怎么样?
有没有办法在scipy.minimize中自动生成多个约束的字典列表?当我使用以下代码时(其中列表约束是同一环上的sage多元多项式列表)
cons = [{'type': 'eq', 'fun': lambda s: ((constraint[0])(*s))},
{'type': 'eq', 'fun': lambda s: ((constraint[1])(*s))},
{'type': 'eq', 'fun': lambda s: ((constraint[2])(*s))},
{'type': 'eq', 'fun': lambda s: ((constraint[3])(*s))}]
y0 = [.5 for xx in x]
bnds = tuple([(0.0, 1.0) for xx in x])
ssoln = scipy.optimize.minimize(HH, y0, jac=dHH, method='SLSQP', bounds=bnds, constraints=cons)
print ssoln
Run Code Online (Sandbox Code Playgroud)
我的输出是
status: 0
success: True
njev: 14
nfev: 22
fun: -2.2669026273652237
x: array([ 0.034829615490635, 0.933405952554424, 0.93340765416238 ,
0.093323548109654, 0.335713397575351, 0.413107862378296])
message: 'Optimization terminated successfully.'
jac: array([-3.321836605297572, 2.640225014918886, 2.640252390205999, …Run Code Online (Sandbox Code Playgroud) 我在这个Sage wiki页面的代码中看到以下代码:
@interact
def _(order=(1..12)):
Run Code Online (Sandbox Code Playgroud)
这个(1..n)语法对Sage来说是独一无二的还是Python中的东西?另外,它做什么?
sage,latex中有一个函数,我希望直接从命令行使用,而不会将sage客户端放入sage中.我认为可能的一种方法是将sage模块包含在我的python脚本中.
使用pip install sage不起作用.
有任何想法吗?
我正在尝试将我的脚本从 mathematica 迁移到 sage。我陷入了一些看似基本的事情中。
我需要使用任意大的多项式,例如以下形式
a00 + a10*x + a01*y + a20 *x^2 + a11*x*y + ...
我只认为它们是 x 和 y 上的多项式,并且我需要给出这样的多项式 P 来获取其单项式列表。
例如,如果 P = a20*x^2 + a12*x*y^2 我想要一个 [a20*x^2,a12*x*y^2] 形式的列表。
我发现 sage 中的多项式有一个名为“coefficients”的类函数,它返回系数;还有一个名为“monomials”的类函数,它返回不带系数的单项式。将这两个列表相乘,得到我想要的结果。
问题是,为了使其工作,我需要显式地将所有 a 声明为变量,但这并不总是可能的。
有没有办法告诉 sage a[number][number] 形式的任何东西都是变量?或者有什么方法可以在 sage 中定义整个变量家族?
在一个完美的世界中,我想让 sage 表现得像 mathematica 一样,从某种意义上说,任何未定义的东西都被视为变量,但我想这太乐观了。
我将在我的 Django Web 应用程序中使用 sage 模块,因此在我的 python virtualenv v3.6 中我使用 pip 安装了 sage。当我运行脚本来使用 sage 时,出现以下错误:
Exception Value: No module named 'sage.all'
Run Code Online (Sandbox Code Playgroud)
我读过一些帖子说 sage 有自己的 python。这是否意味着我不能在 python virtualenv 中使用 sage ?
我SageMath-9.2在我的 mac 上下载,但每次我尝试使用笔记本时
通过sage -n jupyter在我的终端上运行“ ”
我得到以下按摩:
Please wait while the Sage Jupyter Notebook server starts...
Traceback (most recent call last):
File "/Applications/SageMath-9.2.app/Contents/Resources/sage/local/lib/python3.8/site-packages/sage/repl/ipython_kernel/install.py", line 307, in have_prerequisites
from notebook.notebookapp import NotebookApp
File "/Applications/SageMath-9.2.app/Contents/Resources/sage/local/lib/python3.8/site-packages/notebook/notebookapp.py", line 66, in
from tornado import httpserver
File "/Applications/SageMath-9.2.app/Contents/Resources/sage/local/lib/python3.8/site-packages/tornado/httpserver.py", line 29, in
import ssl
File "/Applications/SageMath-9.2.app/Contents/Resources/sage/local/lib/python3.8/ssl.py", line 98, in
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
The Jupyter notebook requires ssl, even …Run Code Online (Sandbox Code Playgroud) 我想使用 sagemath 的立方体组。我做了如下。
python -m pip install sagemath
Run Code Online (Sandbox Code Playgroud)
进而
import sagemath.cubegroup;
Run Code Online (Sandbox Code Playgroud)
在Python脚本中。但我收到以下错误。
ImportError: No module named cubegroup
Run Code Online (Sandbox Code Playgroud)
我尝试了 python2 和 python3 但都不起作用。我也尝试过用 sage 代替 sagemath,但也没有用。
如何在Python上使用sagemath和cubegroup?