Calculating Derivative of f[x] - Why Does Mathematica Give Incorrect Output?

Click For Summary

Discussion Overview

The discussion revolves around the calculation of the derivative of a function defined in Mathematica, specifically addressing an issue where the output differs from the expected result. The focus is on the proper formatting and syntax required in Mathematica for correct interpretation of mathematical expressions.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant presents a function definition and its derivative calculation, questioning why Mathematica produces an unexpected output.
  • Another participant suggests that improper use of parentheses may be causing the issue due to operator precedence in Mathematica.
  • A later reply clarifies that Mathematica interprets "ax" as a single variable rather than the product of "a" and "x," recommending the use of spaces or the multiplication operator for correct formatting.
  • Another participant confirms their expected answer aligns with the correct interpretation and notes that the incorrect output arises from an incomplete application of the quotient rule.
  • A participant reflects on the importance of formatting in Mathematica, sharing an experience with trigonometric functions requiring specific input formats.

Areas of Agreement / Disagreement

Participants generally agree that formatting issues in Mathematica are the source of the discrepancies, but there is no consensus on the broader implications or potential misunderstandings that may arise from these formatting rules.

Contextual Notes

Limitations include the dependence on correct syntax and formatting in Mathematica, which may lead to different interpretations of mathematical expressions. The discussion does not resolve the broader implications of these formatting rules.

ktpr2
Messages
189
Reaction score
0
I have

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

and I get

-2(ax+b)/(d+2x)^2

instead of

ad-2b/(d+2x)^2

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?
 
Physics news on Phys.org
no one has any idea what might be wrong?
 
You're not using parentheses properly. The / operator has a higher precedence than the + operator. Try:

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

- Warren
 
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
 
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 :-p
 
Last edited:
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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
8K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K