You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using NCalc;stringfunction="x^2 + 2";Expressionexpression=new(function);doublemaxValue=double.MinValue;doublemaxArg=0;doubleminValue=double.MaxValue;doubleminArg=0;for(doublex=0;x <= 10;x++){
expression.Parameters["x"]=x;varresult= Convert.ToDouble(expression.Evaluate());if(result>maxValue){maxValue=result;maxArg=x;}if(result<minValue){minValue=result;minArg=x;}}
Console.WriteLine($"Maximum value: {maxValue} at x = {maxArg}");
Console.WriteLine($"Minimum value: {minValue} at x = {minArg}");
Hello, is there a way to calculate the maximum value and the minimum value of a function declared in string function = "x^2 +2" within a range 0 - 10
The text was updated successfully, but these errors were encountered: