minhthien2016

400 Reputation

6 Badges

8 years, 305 days

MaplePrimes Activity


These are questions asked by minhthien2016

I have this code

restart;
with(geometry);
with(StringTools);
interface(worksheetdir);
currentdir(%);
toX := e -> latex(e, 'output' = 'string');
s := toX(e);
s := StringTools:-Substitute(s, "[", "(");
s := StringTools:-Substitute(s, "]", ")");
s := StringTools:-SubstituteAll(s, ",", ";");
s := StringTools:-SubstituteAll(s, "\\frac", "\\dfrac");
s := StringTools:-SubstituteAll(s, "-\\infty", "#@#");
s := StringTools:-SubstituteAll(%, "\\infty", "+\\infty");
s := StringTools:-SubstituteAll(%, "#@#", "-\\infty");
printf("\\documentclass[12pt]{article}\n");
printf("\\usepackage{amsmath,amssymb}\n");
printf("\\usepackage{enumitem}\n");
printf("\\begin{document}\n\n");
f := x -> (x^2 + 4*x + 7)/(x + 1);
df := simplify(diff(f(x), x));
cuctri := sort([solve(df = 0, x)], key = evalf);
g := simplify(diff(df, x));
xcd := rhs(solve([df = 0, g(x) < 0], x)[1]);
xct := rhs(solve([df = 0, 0 < g(x)], x)[1]);
ycd := simplify(f(xcd));
yct := simplify(f(xct));
mycd := coordinates(point(A, xcd, ycd));
myct := coordinates(point(B, xct, yct));
L := [cat("Let a function be given: $y = ", toX(f(x)), "$."), cat("Its derivative is: $y' = ", toX(df), "$."), cat("The maximum point of the graph  $ ", toX(mycd), "$.")];

printf("\\begin{enumerate}[label=\\arabic*)]\n");
for item in L do
    printf("\\item %s\n", item);
end do;
printf("\\end{enumerate}\n\n");

I got

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}[label=\arabic*)]
\item Let a function be given: $y = \frac{x^{2}+4 x +7}{x +1}$.
\item Its derivative is: $y' = \frac{x^{2}+2 x -3}{\left(x +1\right)^{2}}$.
\item The maximum point of the graph  $ [-3, -2]$.
\end{enumerate}

I want to $ (-3; -2)$, not $ [-3, -2]$. How can I make the function toX apply to the whole document?

I tried

restart;
with(geometry);
with(StringTools);
interface(worksheetdir);
currentdir(%);
toX := proc(e) local s; s := latex(e, 'output' = 'string'); s := Substitute(s, "[", "("); s := Substitute(s, "]", ")"); s := SubstituteAll(s, ",", ";"); s := SubstituteAll(s, "\\frac", "\\dfrac"); s := SubstituteAll(s, "-\\infty", "#@#"); s := SubstituteAll(s, "\\infty", "+\\infty"); s := SubstituteAll(s, "#@#", "-\\infty"); return s; end proc;
printf("\\documentclass[12pt]{article}\n");
printf("\\usepackage{amsmath,amssymb}\n");
printf("\\usepackage{enumitem}\n");
printf("\\begin{document}\n\n");
f := x -> (x^2 + 4*x + 7)/(x + 1);
df := simplify(diff(f(x), x));
cuctri := sort([solve(df = 0, x)], key = evalf);
g := simplify(diff(df, x));
xcd := rhs(solve([df = 0, g(x) < 0], x)[1]);
xct := rhs(solve([df = 0, 0 < g(x)], x)[1]);
ycd := simplify(f(xcd));
yct := simplify(f(xct));
mycd := coordinates(point(A, xcd, ycd));
myct := coordinates(point(B, xct, yct));
L := [cat("Let a function be given: $y = ", toX(f(x)), "$."), cat("Its derivative is: $y' = ", toX(df), "$."), cat("The maximum point of the graph  $ ", toX(mycd), "$.")];
printf("\\begin{enumerate}[label=\\arabic*)]\n");
for item in L do
    printf("\\item %s\n", item);
end do;
printf("\\end{enumerate}\n\n");

and got the 

 

\begin{enumerate}[label=\arabic*)]
\item Let a function be given: $y = \dfrac{x^{2}+4 x +7}{x +1}$.
\item Its derivative is: $y' = \dfrac{x^{2}+2 x -3}{\left(x +1\right)^{2}}$.
\item The maximum point of the graph  $ (-3; -2)$.
\end{enumerate}

 

I want to change all `\infty` with `+\infty`. I tried

s := StringTools:-SubstituteAll(s, "\\infty", "+\\infty")

Then,  `-\\infty` to `- + \\infty`. How can I replace \infty with +\infty but keep -\infty unchanged?

I want to write the equation of the line in the form a*x + b*y + c=0, with igcd(a,b,c)=1 of this code

restart;
with(geometry);
point(A, 2, -3);
point(B, -1, 6);
sort(Equation(line(d, [A, B], [x, y])));

I tried by hand

-1/3*sort(Equation(line(d, [A, B], [x, y])))

How can I get the result 3x + y - 3=0 automatically?

PS. I tried and get the answer 3x + y - 3 =0.

restart;
with(geometry);
point(A, 2, -3);
point(B, -1, 6);
eq := sort(Equation(line(AB, [A, B], [x, y])));
k := igcd(coeff(lhs(eq), x), coeff(lhs(eq), y));
sort(eq*sign(coeff(lhs(eq), x))/k);

 

I have this code. In the latex file, I get The vertical asymptote of the graph is $x = -{\dfrac{1}{4}}$. How can I get $x = -\dfrac{1}{4}$.

restart;
with(StringTools);
do_my_list := proc() 
    local toX, my_format; 
    toX := e -> latex(e, 'output' = 'string'); 
    my_format := proc(e)::string; 
        local s::string; 
        s := toX(e); 
        s := SubstituteAll(s, "*", " "); 
        s := StringTools:-SubstituteAll(s, "\\frac", "\\dfrac"); 
        s := StringTools:-SubstituteAll(s, "\\sqrt", "\\sqrt{\\,}"); 
        return s; 
    end proc; 
    return my_format; 
end proc;

L := [(x^2 + 3*x - 7)/(3*x - 2), (x^2 - 4*x + 1)/(4*x + 1)];
fmt := do_my_list();

RR := cat(
"\n\\documentclass[12pt,a4paper]{article}",
"\n\\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}",
"\n\\usepackage[utf8]{vietnam}",
"\n\\usepackage{amsmath}",
"\n\\usepackage{amsthm}",
"\n\\usepackage{enumitem}",
"\n\\theoremstyle{definition}",
"\n\\newtheorem{ex}{Example}",
"\n\\begin{document}\n\n"
);

for i to nops(L) do
    f := L[i];
    TV := solve(denom(f) = 0, x);
    q := simplify(quo(numer(f), denom(f), x));
    TX := q;
    f_ltx := fmt(f);
    TX_ltx := fmt(TX);
    TV_ltx := fmt(TV);
    RR := cat(
        RR,
        sprintf("\\begin{ex} Let be given a function $\\displaystyle y = %s$. We have:\n", f_ltx),
        "\\begin{enumerate}[label=\\arabic*)]\n",
        sprintf("\\item The vertical asymptote of the graph is $x = %s$.\n", TV_ltx),
        sprintf("\\item The oblique (or slant) asymptote of the graph is $y = %s$.\n", TX_ltx),
        "\\end{enumerate}\n\\end{ex}\n\n"
    );
end do;

RR := cat(RR, "\\end{document}");

fout := fopen("baitap_tiemcan.tex", WRITE);
fprintf(fout, "%s", RR);
fclose(fout);
print("Đã tạo file: baitap_tiemcan.tex");
 

I am using S := sort([sqrt(x2), sqrt(y2), sqrt(z2)]);

restart;
n := 0:
L := []:

for a from 3 to 100 do
    for b from 3 to a do
        c2 := a^2 - a*b + b^2;
        c := isqrt(c2);
        if c^2 = c2 then
            if c < a + b and a < b + c and b < c + a then
                if igcd(a, b, c) = 1 then
                    x2 := (-a^2 + b^2 + c^2)/2;
                    y2 := (a^2 - b^2 + c^2)/2;
                    z2 := (a^2 + b^2 - c^2)/2;
                    if 0 < x2 and 0 < y2 and 0 < z2 then
                        S := sort([sqrt(x2), sqrt(y2), sqrt(z2)]);
                        x := S[1]; 
                        y := S[2]; 
                        z := S[3];
                        n := n + 1;
                        L := [op(L), [x, y, z, sqrt(x^2 + y^2), sqrt(y^2 + z^2), sqrt(x^2 + z^2)]];
                    end if;
                end if;
            end if;
        end if;
    end do;
end do;

n;
L;
 

But I get the result. How can I get the correct result of sort? 

1 2 3 4 5 6 7 Last Page 1 of 18