MecSimCalc
ExploreSearchCreateDocsCommunityBlogPricing
    Apps

    Starred
    Go to app
    App Docs

Code:


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}


Output:

{% 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}}
Similar apps:
Education
Math

Copyright © MecSimCalc 2024
Terms | Privacy