Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica bug?

  1. Mar 27, 2005 #1
    I have

    f[x_] := ax+b/2x+d

    and I get


    instead of


    Assuming the above, my answer, is correct, why does mathemetica give me its answer? Is it interpreting one of the variables as some kind of weird constant?
  2. jcsd
  3. Mar 28, 2005 #2
    no one has any idea what might be wrong?
  4. Mar 28, 2005 #3


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    You're not using parentheses properly. The / operator has a higher precedence than the + operator. Try:

    f[x_] := (ax+b)/(2x+d)

    - Warren
  5. Mar 28, 2005 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Oops, nevermind. The problem is that Mathematica thinks "ax," without spaces, is a variable unto itself, different from either a or x. You need to use either spaces or the * operator to indicate multiplication:

    f[x_] := (a*x+b)/(2x+d)

    - Warren
  6. Mar 28, 2005 #5
    Which answer is yours and which answer is mathematica's.

    The answer I get is the ad-2b/(d+2x)^2, the -2(ax+b)/(d+2x)^2 comes from doing only half of the quotient rule equation.

    EDIT: Or just follow the advice above :tongue:
    Last edited: Mar 28, 2005
  7. Mar 28, 2005 #6
    that makes sense. thanks a lot. I'm seeing how delicate things have to be formated. For instance, I just ran into another thing where I realized that my trig functions have to have bracketed variable inputs (Cos [x]) as opposed to Cos (x) which is something else.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook