# Custom Function Return Value Error

I have created the following function which calculates the equation of a curve given it's slope as a derivative and a point.

FunctionName[fnPendiente_, puntoX_, puntoY_ ] := Module[
{factorIntegrante, funcionExacta, solucionGeneral, sol,
valorConstante, solucionParticularCurva },
ClearAll["Global*"];
solucionGeneral = DSolve[y'[x] == fnPendiente , y[x], x];
solucionGeneral = Flatten[solucionGeneral];
sol[x_] = y[x] /. solucionGeneral;
valorConstante = Solve[sol[puntoX] == puntoY, C[1]];
solucionParticularCurva[x_] = sol[x] /. Flatten[valorConstante];
{solucionParticularCurva[x]}
]


But when I call the function:

FunctionName[Sin[3 x] - y[x], 0, 0]


I keep getting the following output:

{y[x]}


Is it something that I am missing or did incorrectly?

• Have you tried to debug it step by step? p.s. ClearAll["Global*"]; is a really nasty side effect. – Kuba Mar 28 '18 at 21:10
• @Kuba Yes I tried but can't seem to figure out exactly where I went wrong. I inserted the ClearAll to see if that would help but it did not. – Omari Celestine Mar 28 '18 at 21:12
• Use DSolve[y'[x] == fnPendiente, y, x] instead. Mathematica is doing some variable renaming when you define sol that is messing up your code. – Carl Woll Mar 28 '18 at 21:12
• @carl-wool Thx. That seems to have been the issue. Could you post it as an answer so I can accept it. – Omari Celestine Mar 28 '18 at 21:52