I'm trying to derive using the math.net.symbolics library.
I am getting this error: Compiler Error CS0103 The name 'cos' does not exist in the current context
private void Form1_Load(object sender, EventArgs e)
{
var x = Expr.Variable("x");
var func = 2 * x * x - 2 * Trigonometric.Contract(cos(x)) 1; //exc. question: 2 * x * x - 2 * cos(x) 1
Console.WriteLine("f(x) = " func.ToString()); //answer: //4*x 2*sin(x)
var derivative = func.Differentiate(x);
Console.WriteLine("f'(x) = " derivative.ToString());
}
CodePudding user response:
The documentation is for F#. it wasn't working because I was writing code in C#.
Problem fixed when I used
x.Cos()
instead of
cos(x)