繁体   English   中英

仍然无法获得基本的Symja评估效果

[英]Still can't get basic Symja evaluation to work

我一直试图让Symja在我的Eclipse项目中工作约一个星期,但到目前为止还没有成功。 看到无数的运行时错误使我感到非常沮丧,因此我希望有人愿意为我解决这个问题。

首先,我使用Project-> Properties-> Java Build Path-> Add External JARs将symja_android_library.rar添加到我的类路径中,然后尝试运行简单的派生计算。 我有个错误,说找不到“ com.google.common.base.Predicate”,所以我用谷歌搜索了这个JAR并安装了它。 它现在被称为“番石榴”,但尽管如此,我还是使用相同的过程将其添加到类路径中。 现在,我可以在类路径中看到com.google.common.base.Predicate,因此该错误消失了。 不幸的是,我现在收到此错误:

java.lang.NullPointerException
    at org.matheclipse.core.eval.EvalEngine.evalLoop(EvalEngine.java:761)
    at org.matheclipse.core.eval.EvalEngine.evalAST(EvalEngine.java:462)
    at org.matheclipse.core.expression.AST.evaluate(AST.java:1078)
    at org.matheclipse.core.eval.EvalEngine.evalLoop(EvalEngine.java:761)
    at org.matheclipse.core.eval.EvalEngine.evalWithoutNumericReset(EvalEngine.java:268)
    at org.matheclipse.core.eval.EvalEngine.evaluate(EvalEngine.java:287)
    at org.matheclipse.core.eval.EvalEngine.addRules(EvalEngine.java:1069)
    at org.matheclipse.core.eval.interfaces.AbstractFunctionEvaluator.setUp(AbstractFunctionEvaluator.java:46)
    at org.matheclipse.core.reflection.system.Power.setUp(Power.java:394)
    at org.matheclipse.core.expression.Symbol.setEvaluator(Symbol.java:327)
    at org.matheclipse.core.eval.Namespace.setEvaluator(Namespace.java:87)
    at org.matheclipse.core.expression.F.$s(F.java:2693)
    at org.matheclipse.core.convert.AST2Expr.convert(AST2Expr.java:188)
    at org.matheclipse.core.convert.AST2Expr.convert(AST2Expr.java:131)
    at org.matheclipse.core.convert.AST2Expr.convert(AST2Expr.java:133)
    at org.matheclipse.core.eval.EvalEngine.parse(EvalEngine.java:979)
    at org.matheclipse.core.eval.EvalUtilities.evaluate(EvalUtilities.java:42)
    at CalculusExample.main(CalculusExample.java:18)

还有System.out.println(); 语句似乎正在输出某些内容,因为我得到以下输出:

Times[d, Power[x, 3]]
Times[integrate, sin, Power[x, 5]]

这是我正在运行的代码:

import com.google.*;
import symja_android_library.*;
import static org.matheclipse.core.expression.F.*;
import org.matheclipse.core.eval.EvalUtilities;
import org.matheclipse.core.interfaces.IAST;
import org.matheclipse.core.interfaces.IExpr;
import org.matheclipse.parser.client.SyntaxError;
import org.matheclipse.parser.client.math.MathException;

public class CalculusExample {
    public static void main(String[] args) {
                try {

                        EvalUtilities util = new EvalUtilities(true);

                        IExpr result;

                        result = util.evaluate("d(x^3)");
                        System.out.println(result.toString());

                } catch (SyntaxError e) {

                        System.out.println(e.getMessage());
                } catch (MathException me) {

                        System.out.println(me.getMessage());
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
}

编辑:我删除了集成,以简化我的问题,并使搜索答案更容易。 我现在只想得出。

有人可以向我解释为什么会发生此错误吗? 从字面上看,我要做的就是在Eclipse项目中进行符号集成和派生。 我要走错路线了吗? 我需要怎么做才能解决此问题?

我会对逐步解决方案感兴趣。 我已尝试解决其他问题,但回答者并未回复我对他们的回答的评论,因此我无法走得很远。 我让人们以他们说的有效代码来回应,所以我知道有一种方法可以使它起作用,我只是弄不清楚它是什么。

我知道已经有一段时间了,但是也许我的评论可以对别人有所帮助。

您输入的字符串错误。 函数d(微分)的调用有两个参数。 第一个是要派生的术语,第二个是变量。 因此,您的输入字符串应为“ d(x ^ 3,x)”。

用于集成的输入字符串应类似于“ integrate(term,{variable,min,max})”

有一个在线演示,您可以在其中尝试表达

symja在线演示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM