Post Reply 
diff command doesn'texecute in a program
08-11-2024, 07:06 AM
Post: #2
RE: diff command doesn'texecute in a program
Hello Victor

What worked for me was to store the expression with the derivative in a string variable (cmd), then use the CAS and EVAL functions. EVAL was necessary because, if not used, the program returned an unevaluated string.

Code:
EXPORT derivada()

BEGIN
local fx, n, cmd, resultado;

// Solicitar al usuario la función y el orden de la derivada
INPUT({{fx,[-1],{27,73,0}},
{n,[0],{46,10,1}}},
{"Derivada de una función f(x)"},{"Funcion f(x):","Orden de la derivada:"},{"",""});

// Calculo de la derivada de orden n de la función f(x)
 cmd:="simplify(diff("+fx+",x,"+n+")";
 resultado:=CAS(EVAL(cmd));

// Mostrar el resultado
PRINT();
PRINT("Función original: "+fx);
PRINT("Derivada de orden "+n+": "+resultado);

// Devolver el resultado
RETURN resultado;

END;


Hope this helps,

Regards.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: diff command doesn'texecute in a program - Patocuy - 08-11-2024 07:06 AM



User(s) browsing this thread: 1 Guest(s)