replaceall text from TeXUtilities

Issue #89 resolved
Dev AM created an issue

4!^(-1)(x-0)^4(D(D(D(D(Cos(x)^2,x),x),x),x)/.x->0)+3!^(-1)(x-0)^3(D(D(D(Cos(x)^ 2,x),x),x)/.x->0)+2!^(-1)(x-0)^2(D(D(Cos(x)^2,x),x)/.x->0)+1!^(-1)(x-0)^1(D(Cos(x)^ 2,x)/.x->0)+(Cos(x)^2/.x->0)

is converted to:

\text{replaceall}({\cos(x)}^{2},x->0)+\frac{{\left( - 0+x\right) }^{1}\,\text{replaceall}(\frac{d}{{dx}}{\cos(x)}^{2},x->0)}{1!}+\frac{{\left( - 0+x\right) }^{2}\,\text{replaceall}(\frac{d}{{dx}}\frac{d}{{dx}}{\cos(x)}^{2},x->0)}{2!}+\frac{{\left( - 0+x\right) }^{3}\,\text{replaceall}(\frac{d}{{dx}}\frac{d}{{dx}}\frac{d}{{dx}}{\cos(x)}^{2},x->0)}{3!}+\frac{{\left( - 0+x\right) }^{4}\,\text{replaceall}(\frac{d}{{dx}}\frac{d}{{dx}}\frac{d}{{dx}}\frac{d}{{dx}}{\cos(x)}^{2},x->0)}{4!}

what is this "replaceall" text?

The input is "Taylor(cos(x)^2, {x,0,4})"

Comments (6)

  1. Axel Kramer repo owner

    Did you evaluate the Taylor expression first?

    Try this snippet:

    import java.io.StringWriter;
    
    import org.matheclipse.core.basic.Config;
    import org.matheclipse.core.eval.EvalEngine;
    import org.matheclipse.core.eval.TeXUtilities;
    import org.matheclipse.core.interfaces.IExpr;
    import org.matheclipse.parser.client.SyntaxError;
    import org.matheclipse.parser.client.math.MathException;
    
    public class Issue89Example {
        public static void main(String[] args) {
            try {
                // false -> distinguish between upper- and lowercase identifiers:
                Config.PARSER_USE_LOWERCASE_SYMBOLS = true;
                EvalEngine engine = new EvalEngine(true);
                TeXUtilities texUtil = new TeXUtilities(engine, true);
    
                StringWriter stw = new StringWriter();
                IExpr result = engine.evaluate("Taylor(Cos(x)^2, {x,0,4})");
                texUtil.toTeX(result, stw);
                System.out.println(stw.toString());
    
            } catch (SyntaxError e) {
                // catch Symja parser errors here
                System.out.println(e.getMessage());
            } catch (MathException me) {
                // catch Symja math errors here
                System.out.println(me.getMessage());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    
  2. Dev AM reporter

    I listen to steps with the steplistener. One of the steps is the one I mentioned in the first post, and when i try to convert it to tex, symja return me the string I posted above. The problem is not the evaluation perse, but the tex conversion...i suppose :/

    The example you gave me is ok, it returns the same result to me (1-x^{2}+\frac{x^{4}}{3})

  3. Dev AM reporter

    This solved the "issue". then..sometimes in generated tex strings appear a "/."

    eg. Cos(x)^2/.x->0

    Immagine.png

  4. Log in to comment