
Hi Dmitry,
one question about the derivativefunction.
I mean, if I make deriv("cos(x)", "x") the result should be "sin(x)",
On my Casio, it is this result and I can calculate "deriv("cos(x)","x")*2 and the result should be
"2sin(x)".
How does it work?
Regards



What is "Casio"?
If you input "deriv(cos(x)) * 2", it will not calculate. Because in the Derivative class the Calculate method always throws NotSupportedException.
In code you can calculate "deriv(cos(x))" and save to local variable. And then create new mul expression from result of "deriv(cos(x))" and "2".



Hi,
Casio is the company of my graphical hardware calculator.
With this calculator I check some functions of your library.
So, I've created a mul function like this,
var parser = new Parser();
var mul = new Mul ( parser.Parse ( "deriv(cos(x))", new Number ( 2 ) ) );
but I can't calculate the Result, because the derivclass can't calculate.
Is there something wrong?
Regards



var processor = new MathProcessor();
var exp = processor.Solve("deriv(cos(x))"); // will be sin(x)
var mul = new Mul(exp, new Number(2));
// I don't check this code in VS.


Jun 17, 2014 at 7:15 PM
Edited Jun 17, 2014 at 7:34 PM

ok, than I have the mulexpression, but how can I get the result? like 2sin(x)
var proc = new Processor();
var result = proc.Solve ( "deriv(cos(x),x)" );
// this also doesn't work
// it raises an exception in the DifferentiatiorClass



Sorry.
var processor = new Processor();
var exp = processor.Solve<ExpressionResult>("deriv(cos(x))").Result; // sin(x)
or use Differentiate method or Differentiator class.


Jun 17, 2014 at 9:15 PM
Edited Jun 17, 2014 at 9:17 PM

It raises an exception.
var proc = new Processor ();
var result = proc.Solve<ExpressionResult> ("deriv(cos(x),x)");
It doesn't work.
I want to parse something like this "deriv(cos(x),x) * 2" and the computed result should be 2*sin(x) and I hope
this feature is implemented.
Maybe, the ToString()Method of deriv should return its derived argument.
for example, deriv(cos(x),x) * 2
parent is mul and its left argument is deriv and its right arg is number 2 so thats MulToString()Method should return sin(x) * 2.
and than it should be calculated correctly.
but its only a little idea.
Regards



You can parse "deriv(cos(x),x) * 2" but it doesn't work.
For now, only way is parse "deriv(cos(x),x)", differentiate it and create new expression.
May be later I implement the Calculate method in the Derivative class, and then "deriv(cos(x),x) * 2" will work.



what I have to do to implement it by myself?
I will give you a pull req. if it is finished.
pseudo:
calculate (params) {
var exp = Differentiate ( Argument, Variable );
return exp.Calculate(params);
}
But the result is not an expression. Like 2*Sin(x),
Another question: Is it possible to return a short expression as result, like 2sin(x), without '*',
because,



Another question: Is it possible to return a short expression as result, like 2sin(x), without ''  you need reimplement ToString in Mul.cs.
pseudo:
calculate (params) {
var exp = Differentiate ( Argument, Variable );
return exp.Calculate(params);
}
Result will be result of calculation (2sin(x)) (if 'x' is set).
Ability to parse "deriv(cos(x),x) * 2" and get "2sin(x)" is not supported.

