Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
0 votes

Hi,
I have an expression of substitution rule / equation, where the right-hand-side has numerous terms. When I tried calling simplify(_), it returned an error that I think is coming when the algorithm tries to run on both sides of the equation.

So I used get_rhs() from the manip library,

extemp = manip.getrhs(exp_full);

and performed the simplification steps on extemp.
However now ex
temp is not an equation, so when I use the function multiply_through() - I get an error.

My two questions are:

(1) Is there a way to multiply an expression which is not an equation by a factor, like multiply_through does

(2) How do I "return" the value of my non-equation ex_temp into an equation expression? like

exfullnew := Y -> (ex_temp);

I assume it has something to do with nodes of expressions. In the manual section I see a list of functions under cdb.utils.node, but they all return values, not updating them.

Thanks in advance,
Amnon

asked in General questions by (200 points)

1 Answer

0 votes

You can multiply expressions like this:

 ex:= A+B+C;
 ex:= (D+E) @(ex);

I am not entirely sure what you mean with (2). Do you mean that you have two expressions and you want to turn them into an equation by setting one equal to the other? Something like

lhs:= A+B;
rhs:= C+D;
ex:= @(lhs) = @(rhs);

?

Finally, if you think simplify has a bug when acting on equations, please try to provide a minimal example and send that to me, so it can be fixed.

answered by (61.5k points)

Thanks for the reply,
Your suggestions work perfectly.

About the error using simplify() - I emailed you an example notebook that leads to the error.
When I use Cadabra cloud I get this message

SyntaxError: unexpected character after line continuation character (, line 1)

At: /opt/tljh/user/lib/python3.6/site-packages/sympy/parsing/sympyparser.py(879): evalexpr /opt/tljh/user/lib/python3.6/site-packages/sympy/parsing/sympyparser.py(966): parseexpr (2):

When I use my Cadabra build with jupyter notebook I get the traceback:

Traceback (most recent call last): File
"/usr/local/lib/python3.9/site-packages/cadabra2jupyter/kernel.py",
line 54, in do
execute
self.executepython(pycode) File "/usr/local/lib/python3.9/site-packages/cadabra2jupyter/kernel.py",
line 108, in _execute
python
self.sandboxcontext(pycode) File "/usr/local/lib/python3.9/site-packages/cadabra2jupyter/context.py",
line 51, in call
exec(code, self.
sandbox) File "", line 1, in File "/usr/lib/python3/dist-packages/sympy/parsing/sympyparser.py",
line 1008, in parse
expr
return evalexpr(code, localdict, globaldict) File "/usr/lib/python3/dist-packages/sympy/parsing/sympyparser.py", line
902, in eval_expr
expr = eval( File "", line 1

...