我正在尝试创建一个程序,它使用sympy来获取一组变量并在这些变量的域上评估符号逻辑表达式.问题是我不能让python在吐出真值表后评估表达式.
这是代码:
from sympy import *
from sympy.abc import p, q, r
def get_vars():
vars = []
print "Please enter the number of variables to use in the equation"
numVars = int(raw_input())
print "please enter each of the variables on a newline"
for i in xrange(numVars):
vars.append(raw_input())
return vars
def get_expr():
print "Please enter the expression to use"
return str(raw_input())
def convert_to_expr(inputStr):
return eval(inputStr)
def main():
vars = get_vars()
expr = get_expr()
print("recieved input: " + str(vars) + " expr …Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用C++的几个计算机代数库来使用我正在进行的矢量微积分课程.我在GiNaC和SymbolicC++中遇到了非线性方程式的问题.
这是一个简单的例子,但问题是我无法弄清楚如何评估数字并可能将其转换为double或float:
#include <iostream>
#include "symbolicc++.h"
using namespace std;
int main(void)
{
Symbolic x("x"), y("y");
Equation e1 = (x^2) + (y^2) == 13;
Equation e2 = (x^2) - y == 7;
Equations eqs = {e1, e2};
list<Symbolic> symbs = {x, y};
list<Equations> sols = solve(eqs, symbs);
Symbolic x_sol, y_sol;
int i = 1;
for( auto iter1 = sols.begin(); iter1 != sols.end(); iter1++)
{
x_sol = x.subst((*(*iter1).begin()));
y_sol = y.subst((*(--(*iter1).end())));
cout << "p" << i << " = {" …Run Code Online (Sandbox Code Playgroud) 我只是想在matlab中解决方程,但它确实给了我一个警告. "警告显式积分无法找到" 经过一些搜索后,人们建议用Double()方法包装我的方程式,但即便如此,我收到错误答案(ans = 0),我在mathematica/maple上计算为4.62240566.

我认为它与浮点有关,但我不确定如何修复它
syms t
int( (t^2+100)^(-1/2)*exp(-10^-3*(t^2 + 100)^(1/2)),t , 1, Inf)
Warning: Explicit integral could not be found.
Run Code Online (Sandbox Code Playgroud) 如何在R中找到矩阵的符号反转; 例如:
Matrix.test <- function(x) matrix(c(x, x^2, x^3, x^4, x^5, x^6, x^7, x^8, x^9, 2*x, 3*x, 4*x, 2*x^2, 3*x^3, 4*x^4, 5*x^5), 4, 4)
Run Code Online (Sandbox Code Playgroud)
我知道有一个名为'Ryacas'的包,它是'yacas'的接口,但我不能用它来做这样的计算.'yacas'是一个用于符号操纵数学表达式的程序.请参阅链接了解更多详情.
谢谢