| compare_expressions | Function (ROM Call 0x2C0)

AMS 1.01 or higher | estack.h

short compare_expressions (CESI ptr1, CESI ptr2);

Compares two expressions.

compare_expressions returns 0 if two expressions pointed to by ptr1 and ptr2 are equal in the sense that they have the same structure, variables, function names, and numbers that compare equal. A float and a rational number compare equal if converting the rational number to a float produces an identical number. If the expressions are not, it returns a non-zero value which may be positive or negative (more precise, 1 or -1). Positive result means that the expression pointed to by ptr1 is "more main" that the expression pointed to by ptr2, and negative result means "less main". Principally, variables are more main than symbolic constants such as pi, which are more main than numbers. In expressions such as `'expand(...,var)'` or `'Integral(...,var)'`, a variable var is "most main". Otherwise, the 26 Roman one-letter variables order r>>s>>...>>z>>a>>b>>...>>q ('>>' means "more main"), which order more main than all other variables, which order alphabetically. Functions and operators are typically ordered by recursively comparing their first arguments, with ties broken by comparing their second arguments, etc. then finally comparing the operators or functions, if necessary. For example:

- -2.0 and -2 are equal;
- -2.0 is less main than -1;
- pi is more main than 4;
- `x` is more main than 4;
- `x` is less main than `r`;
- `x` is more main than `ln(y)`;
- `x` is less main than `ln(x)`.

Note: Both expressions should be in internal canonic form (see push_internal_simplify), else this function may not work as expected.

Uses: lead_base_index, next_expression_index, cmpstri, strcmp, compare_numbers, Integer1Index, primary_tag_list, ROM Call 0x5E2
Used by: cmd_sorta, cmd_sortd, did_push_anti_deriv, did_push_series, push_1st_derivative, push_abs, push_acosh, push_asin, push_asinh, push_atan, push_atanh, push_comdenom, push_csolve, push_czeros, push_def_int, push_denominator, push_desolve, push_expand, push_factor, push_floor, push_im, push_lim, push_max, push_max2, push_median, push_min, push_min2, push_nsolve, push_numerator, push_phase, push_re, push_sign, push_sin2, push_solve, push_zeros, did_push_to_polar, push_and, push_equals, push_exponentiate, push_greater_than, push_greater_than_or_equals, push_less_than, push_less_than_or_equals, push_negate, push_not_equals, push_or, push_product, push_sum, push_to_cylin, push_to_sphere, add_to_top, are_units_consistent, did_push_divide_units, get_ub, GM_Intersect, index_if_pushed_binomial_info, index_if_pushed_qquad_info, next_var_or_kernel_index, push_auto_units_conversion, push_but_factor, push_but_term, push_constant_factors, push_constant_terms, push_dependent_factors, push_dependent_terms, push_gcd_then_cofactors, push_independent_factors, push_independent_terms, push_make_proper, push_nonconstant_factors, push_nonconstant_terms, push_nonnumeric_factors, push_poly_deg_in_var_or_kernel, push_poly_qr, push_reciprocal, push_standardize, raise_to_top, replace_top_with_post_simplified, replace_top2_with_pow, replace_top2_with_sum, ROM Call 0x48D