import sympy as sp
def check_expressions_equal(expr1_str, expr2_str):
"""
Check if two mathematical expressions, given as strings, are equal.
"""# Convert the string representations to SymPy expressions
expr1 = sp.sympify(expr1_str)
expr2 = sp.sympify(expr2_str)
# Simplify the difference between the two expressions# and check if the result is equal to zeroreturn sp.simplify(expr1 - expr2) == 0, expr1, expr2
def main(inputs):
expr1=inputs['func_1']
expr2=inputs['func_2']
res, expr1, expr2 = check_expressions_equal(expr1,expr2)
# convert to latex expression
latex_expr1 = sp.latex(expr1)
latex_expr2 = sp.latex(expr2)
return {"result": res, "String1": latex_expr1, "String2": latex_expr2}
{% if outputs.result %}
These two equations are the same
{% else %}
These two equations are not the same
{% endif %}
Equation 1: {{ outputs.String1 | katex}}
Equation 2: {{ outputs.String2 | katex}}
Copyright © MecSimCalc 2025
Terms | Privacy