Ejemplo n.º 1
0
        private static void GenerateLogSimplifications()
        {
            Rule logToLn = new Rule(Log.LogToLnRunnable, Log.LogToLn, "log(e,f(x)) - > ln(f(x))");

            //This rule only can be a preprocessor rule and therefore should not be added to the rule manager!
            Rule LnToLog = new Rule(Log.LnToLogRunnable, Log.LnToLog, "ln(f(x)) -> log(e,f(x))");

            //These are candidates for preprocessing and post processing:
            Rule logOne            = new Rule(Log.LogOneRunnable, Log.LogOne, "log(b,1) -> 0");
            Rule logIdentical      = new Rule(Log.LogIdentitcalRunnable, Log.LogIdentitcal, "log(b,b) -> 1");
            Rule logPowerExpansion = new Rule(Log.LogExponentExpansionRunnable, Log.LogExponentExpansion, "log(b,R^c) -> c * log(b,R)");

            logOne.AddPreProcessingRule(LnToLog).AddPostProcessingRule(logToLn);
            logIdentical.AddPreProcessingRule(LnToLog).AddPostProcessingRule(logToLn);
            logPowerExpansion.AddPreProcessingRule(LnToLog).AddPostProcessingRule(logToLn);

            Rule logPower = new Rule(Log.LogPowerRunnable, Log.LogPower, "b^log(b,x) -> x");

            Rule logSummation   = new Rule(Log.LogSummationRunnable, Log.LogSummation, "log(b,R) + log(b,S) -> log(b,R*S)");
            Rule logSubtraction = new Rule(Log.LogSubtractionRunnable, Log.LogSubtraction, "log(b,R) - log(b,S) -> log(b,R/S)");

            Rule lnPower          = new Rule(Log.LnPowerRunnable, Log.LnPower, "e^ln(f(x)) -> f(x)");
            Rule lnSummation      = new Rule(Log.LnSummationRunnable, Log.LnSummation, "ln(R) + ln(S) -> log(e,R) + log(e,S) -> ln(R*S)");
            Rule lnSubtraction    = new Rule(Log.LnSubtractionRunnable, Log.LnSubtraction, "ln(R) - ln(S) -> log(e,R) - log(e,S) -> ln(R/S)");
            Rule lnPowerExpansion = new Rule(Log.LnPowerRuleRunnable, Log.LnPowerRule, "ln(R^c) -> c*ln(R)");

            ruleManager.Add(AST.SimplificationMode.Log, logOne);
            ruleManager.Add(AST.SimplificationMode.Log, logIdentical);
            ruleManager.Add(AST.SimplificationMode.Log, logPower);
            ruleManager.Add(AST.SimplificationMode.Log, logPowerExpansion);

            ruleManager.Add(AST.SimplificationMode.Log, logSummation);
            ruleManager.Add(AST.SimplificationMode.Log, logSubtraction);
            ruleManager.Add(AST.SimplificationMode.Log, lnSummation);
            ruleManager.Add(AST.SimplificationMode.Log, lnSubtraction);

            ruleManager.Add(AST.SimplificationMode.Log, lnPowerExpansion);
            ruleManager.Add(AST.SimplificationMode.Log, lnPower);

            ruleManager.Add(AST.SimplificationMode.Log, logToLn);
        }