How much do they differ? I checked the issue and the latest result wasn't
that bad, although probably too much to blame floating-point errors.
However, if you push the numerical range into e.g. denormalized numbers I
guess it can simply be that. Not very likely though. Is it still that type
of numerical errors?

BR Oscar

Den tors 22 okt. 2020 09:37Jason Moore <[email protected]> skrev:

> Howdy,
>
> I'm trying to track down a bug in this PR:
>
> https://github.com/pydy/pydy/pull/122
>
> I have quite large SymPy expressions which I evaluate with floating point
> numbers. I also cse those expressions and evaluate those with the same
> floating point numbers. I'm getting discrepancies in the results. I'd like
> to eliminate the possibility that the cse'd expressions are different from
> the original expression. I wrote this naive function to make the comparison:
>
> def compare_cse(expr):
>
>     args = list(expr.free_symbols)
>     args.remove(TIME)
>     args += me.find_dynamicsymbols(expr)
>     args = list(sm.ordered(args))
>     vals = list(np.random.random(len(args)))
>
>     eval_expr = sm.lambdify(args, expr)
>     res = eval_expr(*vals)
>
>     replacements, reduced_expr = sm.cse(expr)
>     for repl in replacements:
>         var = repl[0]
>         sub_expr = repl[1]
>         eval_sub_expr = sm.lambdify(args, sub_expr)
>         vals.append(eval_sub_expr(*vals))
>         args.append(var)
>     eval_reduced_expr = sm.lambdify(args, reduced_expr[0])
>     cse_res = eval_reduced_expr(*vals)
>
>     np.testing.assert_allclose(res, cse_res)
>
> This seems to work for small expressions, but for the large expressions
> run this actually kills my Python interpreter after some minutes.
>
> Is there a better way to write this? I need some way to verify that
> numerical evaluation of a cse'd expression gives the same result as
> numerical evaluation of the expression that can actually complete in a
> reasonable amount of time.
>
> Jason
> moorepants.info
> +01 530-601-9791
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/CAP7f1Aivs53AcwyaoyO5%2Bzkn%2BPrX3TfoJJ5X85qQNZ6JRbo5JQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/sympy/CAP7f1Aivs53AcwyaoyO5%2Bzkn%2BPrX3TfoJJ5X85qQNZ6JRbo5JQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAFjzj-LQNBFoF7Q4Rb%2BZG3J35-Et9b__SED-DMJvwUYqyKYADQ%40mail.gmail.com.

Reply via email to