# Force expression in certain form

Is there a function in Mathematica to force an expression to be transformed into a given form. For example f[x] is a function of x with known symbolic expression, and the goal is to find constants A and B such that f[x] = A*x + B.

Is yes, is this also possible in Wolfram Alpha?

• This is sorta kinda vague. If f[x] is indeed linear, then yes; otherwise, where are A and B supposed to come from? Commented Apr 7, 2016 at 9:52
• The actual case was having is f[x] = A + B/x, so I wondered if Mathematica can determine if an expression can be written in that form. Commented Apr 7, 2016 at 10:06
• Perhaps Reduce[f[x] == a /x + b, {x}] // FullSimplify could be a start. Also please update your question to ask exactly what you need. Commented Apr 7, 2016 at 10:47
• WolframAlpha does not understand user defined functions, so no this is not possible in WolframAlpha. In Mathematica you might try adapt this example to if it can do what you want: f[x] = Sin[x]* x + Tan[3]; f[x] /. {a_* x + b_ -> A* x + B} will then display B + A x. Or possibly f[x] /. {a_* x + b_ -> HoldForm[A* x + B]} which returns A x+B. But that does not assign any values to A or B that you can later use, it just successfully does the substitution and displays that. If you need more or different results then please edit your question to be more precise and detailed.
– Bill
Commented Apr 7, 2016 at 17:17