1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Why Do Two Similar Code Snippets Yield Different Results for Symbolic Equations?

Discussão em 'Python' iniciado por Stack, Setembro 11, 2024.

  1. Stack

    Stack Membro Participativo

    I am calculating (what seems to me) the same thing in two ways but am getting different results. I'd appreciate any help in understanding the reason behind this.

    I have a list of symbolic equations, each defined as:

    a1 * x1 + a2 * x2 + ... + a30 * x30 = b

    eqs=[] # expressions
    reps={} # values of symbols in the expressions
    b=[] # numeric value that the known expression has
    for i,e in enumerate(eqs):
    A = (e-b).subs(reps)
    B = e.subs(reps)-b
    if A != B:
    print (A, B)


    These are giving different results for A and B:

    [​IMG]

    Continue reading...

Compartilhe esta Página