I want to test if expressions (mix of variables, functions and numbers) are zero valued, as fast as possible, and PossibleZeroQ is sometimes very slow. One solution I found was to substitute the variables for random reals and test if the value of the substituted expression is less than, say, $0.0001$.
It works good, but maybe there are other solutions out there.
I know it can cause some wrong answers, but what is most important is the speed, since I can check the false positive later with PossibleZeroQ.
Can you think of an algorithm that can perform fast zero value tests in detriment of some loss of accuracy?
Edit:
I'll post my algorithm here:
TestZeroValuedExpression[expression_,symbolslist_]:=Module[{numericvalue},
Quiet[TimeConstrained[If[Check[
numericvalue=N[Expand[expression/.Table[symbolslist[[i]]->RandomReal[{1,2}],{i,Length[symbolslist]}]]];
,False]=!=False,
If[Abs[numericvalue]>0.00001,False,PossibleZeroQ[expression]],
PossibleZeroQ[expression]
],3,False]]
];
PossibleZeroQwork very slowly. Look e.g. here Most efficient way to determine conclusively whether an algebraic number is zero.PossibleZeroQwon all those tests. – Artes Sep 11 '13 at 20:19NandChop[ N@expr_, delta]e.g.test[expr_, a_] := Chop[ N[expr /. x :> RandomReal[{-a, a}]], a]– Artes Sep 11 '13 at 21:08