I'm not sure what that line of code is doing. You'd have to trace through to see exactly what sequence of tokens can lead to it being run.
However, I will say in general that it would make sense to me to split out implicit multiplication via a space and implicit multiplication via parentheses. It's only the latter that is ambiguous with function application. Unfortunately, this is a general ambiguity that is inherent in mathematical notation. Does x(y + z) mean x is a function of y + z or does it mean xy + xz? There's no way to know from the notation alone. Aaron Meurer On Mon, Nov 22, 2021 at 11:30 AM Paul Royik <[email protected]> wrote: > > I've found the following piece of code in _implicit_multiplication > > elif (isinstance(tok, AppliedFunction) and > nextTok[0] == OP and nextTok[1] == '('): > # Applied function followed by an open parenthesis > if tok.function[1] == "Function": > result[-1].function = (result[-1].function[0], 'Symbol') > result.append((OP, '*')) > > Is there any reason to substitute a Function with a Symbol? > > On Monday, November 22, 2021 at 9:00:13 AM UTC+2 Paul Royik wrote: >> >> I want to parse something like `f(x) - 2 sin 3x`. >> >> If I use `parse_expr` without `implicit_multiplication_application`, then >> `f(x)` is parsed correctly, but not `2 sin 3x`. >> >> If I include `implicit_multiplication_application`, then `f(x)` is parsed as >> `fx`. >> >> Is this a bug? > > -- > 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/7daad2ef-415d-46af-a9dc-92bb2006fa1bn%40googlegroups.com. -- 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/CAKgW%3D6K10KJ%2BaN3UD3Pvt6Cp5bxqVttsXp4g8za6Fi5At%2BmnGg%40mail.gmail.com.
