Laurenso

25 Reputation

One Badge

1 years, 53 days

MaplePrimes Activity


These are questions asked by Laurenso

I want to make a list of ex, and in each of ex contains some item of enumerare. This is my code:

restart;
with(geometry);
mylist := [[-1, 9, -15], [1, -6, -15], [1, -6, 9], [1, 6, 12], [-2, 3, 12], [2, -9, 12], [-1, -6, -9], [-1, -9, -15], [1, 6, -15], [-2, 9, -12], [1, 3, 3], [-1, 6, -9], [3, -4, 2], [-5, 5, -2], [-3, -5, -4], [-2, 1, -3], [-5, -4, -2], [5, 5, 4], [-1, -2, -2], [-3, 1, -5]];
toX := s -> latex(s, output = string);
s := "";
for item in mylist do
    a := item[1];
    b := item[2];
    c := item[3];
    f := x -> a*x^3 + b*x^2 + c*x;
    sol := solve(diff(f(x), x) = 0, x);
    x1 := sol[1];
    x2 := sol[2];
    f2 := diff(f(x), x, x);
    if subs(x = x1, f2) < 0 then
        max_point := [x1, f(x1)];
    elif subs(x = x2, f2) < 0 then
        max_point := [x2, f(x2)];
    else
        max_point := "No maximum";
    end if;
    point(o, 0, 0);
    point(A, x1, f(x1));
    point(B, x2, f(x2));
    AB := simplify(distance(A, B));
    d := Equation(line(k, [A, B], [x, y]));
    lined := sort(sign(coeff(lhs(d), x))*d/igcd(coeff(lhs(d), x), coeff(lhs(d), y)));
    myr := distance(o, k);
    circle_eq := x^2 + y^2 = myr^2;
    s := cat(s, "\\begin{ex}\n", "  Given the function $y = ", toX(f(x)), "$.\n", "  \\begin{enumerate}[label=\\alph*)]\n", "    \\item The derivative of the function is $y'=", toX(diff(f(x), x)), "$.\n", "    \\item The maximum point of the function's graph is $P(", toX(max_point[1]), ", ", toX(max_point[2]), ")$.\n", "    \\item The equation of the line passing through the two extremum points of the graph is $", toX(lined), "$.\n", "    \\item The distance between the two extremum points $A$ and $B$ is $", toX(AB), "$.\n", "    \\item The equation of the circle with center at the origin and tangent to the line passing through the two extremum points is $", toX(circle_eq), "$.\n", "  \\end{enumerate}\n", "\\end{ex}\n\n");
end do;
printf("%s", s);


It seems there is a bug, I get a massage Error, (in geometry:-line) the line is not defined. 

How can I prepare it? and how can I reduce the code? 

I have a list

mylist := [[sqrt(-5*x^2 - 5*x - 1) = -4*x - 1, {-1/3, -2/7}], [sqrt(-5*x^2 - 5*x - 1) = x + 1, {-1/2, -2/3}], [sqrt(-5*x^2 - 5*x - 1) = 4*x + 3, {-2/3, -5/7}], [sqrt(-5*x^2 - 5*x + 4) = -5*x + 3, {1/2, 1/3}], [sqrt(-5*x^2 - 4*x + 2) = -5*x + 2, {1/3, 1/5}], [sqrt(-5*x^2 - 4*x + 2) = -2*x + 1, {-1/3, 1/3}]]

I tried
latex(mylist) and get
 

\left[\left[\sqrt{-5 x^{2}-5 x -1} = -4 x -1, \left\{-{\frac{2}{7}}, -
{\frac{1}{3}}\right\}\right], \left[\sqrt{-5 x^{2}-5 x -1} = x +1, 
\left\{-{\frac{2}{3}}, -{\frac{1}{2}}\right\}\right], \left[
\sqrt{-5 x^{2}-5 x -1} = 4 x +3, \left\{-{\frac{5}{7}}, -{\frac{2}{3}}
\right\}\right], \left[\sqrt{-5 x^{2}-5 x +4} = -5 x +3, \left\{{\frac
{1}{2}}, {\frac{1}{3}}\right\}\right], \left[\sqrt{-5 x^{2}-4 x +2} = 
-5 x +2, \left\{{\frac{1}{3}}, {\frac{1}{5}}\right\}\right], \left[
\sqrt{-5 x^{2}-4 x +2} = -2 x +1, \left\{-{\frac{1}{3}}, {\frac{1}{3}}
\right\}\right]\right]

How can I get  a latex like this?

\documentclass[12pt,a4paper]{article}
\usepackage[left=1.5cm, right=1.5cm, top=2cm, bottom=2cm]{geometry}
\usepackage{fouriernc}
\usepackage{enumitem}
\usepackage{amsmath}
\begin{document}
	Solve the following equations:
	\begin{enumerate}[label=\arabic*)]
		\item $\sqrt{-5 x^{2}-5 x -1} = -4 x -1.$ \hfill Answer: $\left\{-{\dfrac{2}{7}}, -{\dfrac{1}{3}}\right\}.$
		\item $\sqrt{-5 x^{2}-5 x -1} = x +1.$ \hfill Answer: $\left\{-{\dfrac{2}{3}}, -{\dfrac{1}{2}}\right\}.$
		\item $\sqrt{-5 x^{2}-5 x -1} = 4 x +3.$ \hfill Answer: $\left\{-{\dfrac{5}{7}}, -{\dfrac{2}{3}}\right\}.$
		\item $\sqrt{-5 x^{2}-5 x +4} = -5 x +3.$ \hfill Answer: $\left\{{\dfrac{1}{2}}, {\dfrac{1}{3}}\right\}.$
		\item $\sqrt{-5 x^{2}-4 x +2} = -5 x +2.$ \hfill Answer: $\left\{{\dfrac{1}{3}}, {\dfrac{1}{5}}\right\}.$
	\end{document}


I make a function 
myf := (a, b, c) -> [a*x^2 + b*x + c = 0, solve(a*x^2 + b*x + c = 0, {x})];

I tried 

myf(1, 2, -3);

and get

[x^2 + 2*x - 3 = 0, {x = 1}, {x = -3}]

With list mylist := [[1, 2, -3], [3, 2, -1]];

How can I map myf  onto mylist?

I tried 

myf := (a, b, c) -> [a*x^2 + b*x + c = 0, solve(a*x^2 + b*x + c = 0, {x})];
mylist := [[1, 2, -3], [3, 2, -1]];
map(myf, mylist);

I can not get the result. 

I am trying to print all the equations of sphere in the form (x-a)^2 + (y-b)^2 + (z-c)^2-10^2=0?
my code
restart;
n := 0;
for a to 5 do
    for b to 5 do for c to 5 do mysphere := (x - a)^2 + (y - b)^2 + (z - c)^2 - 10^2 = 0;
if a*b*c <> 0 and igcd(a, b, c) = 1 then n := n + 1; L[n] := [a, b, c];
end if;
end do;
end do;
end do;
L := convert(L, list);
map(mysphere, L);
print(mysphere);


I don't get the correct results. How can get correct results?

list:= [[-12, 3, 5], [-11, -2, 5], [-11, -1, 2], [-11, -1, 8], [-11, 0, 
        1], [-11, 0, 9], [-11, 3, 0], [-11, 3, 10], [-11, 6, 1], [-11, 6, 
        9], [-11, 7, 2], [-11, 7, 8], [-11, 8, 5], [-4, -9, 5], [-4, 
        3, -7], [-4, 3, 17], [-4, 15, 5], [-3, -9, 2], [-3, -9, 8], [-3, 
        0, -7], [-3, 0, 17], [-3, 6, -7], [-3, 6, 17], [-3, 15, 2], [-3, 15,
        8], [-2, -9, 1], [-2, -9, 9], [-2, -1, -7], [-2, -1, 17], [-2, 
        7, -7], [-2, 7, 17], [-2, 15, 1], [-2, 15, 9], [1, -10, 5], [1, -9, 
        0], [1, -9, 10], [1, -2, -7], [1, -2, 17], [1, 3, -8], [1, 3, 
        18], [1, 8, -7], [1, 8, 17], [1, 15, 0], [1, 15, 10], [1, 16, 
        5], [4, -9, 1], [4, -9, 9], [4, -1, -7], [4, -1, 17], [4, 
        7, -7], [4, 7, 17], [4, 15, 1], [4, 15, 9], [5, -9, 2], [5, -9, 
        8], [5, 0, -7], [5, 0, 17], [5, 6, -7], [5, 6, 17], [5, 15, 2], [5, 
        15, 8], [6, -9, 5], [6, 3, -7], [6, 3, 17], [6, 15, 5], [13, -2, 
        5], [13, -1, 2], [13, -1, 8], [13, 0, 1], [13, 0, 9], [13, 3, 
        0], [13, 3, 10], [13, 6, 1], [13, 6, 9], [13, 7, 2], [13, 7, 
        8], [13, 8, 5], [14, 3, 5]];
These points are lies on the sphere (x - 1)^2 + (y - 3)^2 + (z - 5)^2 = 13^2. How to write the equation of the planes tangent to the sphere at the points in the list? This is some equations.
I tried

restart;
with(geom3d);
L := [[-12, 3, 5], [-11, -2, 5], [-11, -1, 2], [-11, -1, 8], [-11, 0, 1], [-11, 0, 9], [-11, 3, 0], [-11, 3, 10], [-11, 6, 1], [-11, 6, 9], [-11, 7, 2], [-11, 7, 8], [-11, 8, 5], [-4, -9, 5], [-4, 3, -7], [-4, 3, 17], [-4, 15, 5], [-3, -9, 2], [-3, -9, 8], [-3, 0, -7], [-3, 0, 17], [-3, 6, -7], [-3, 6, 17], [-3, 15, 2], [-3, 15, 8], [-2, -9, 1], [-2, -9, 9], [-2, -1, -7], [-2, -1, 17], [-2, 7, -7], [-2, 7, 17], [-2, 15, 1], [-2, 15, 9], [1, -10, 5], [1, -9, 0], [1, -9, 10], [1, -2, -7], [1, -2, 17], [1, 3, -8], [1, 3, 18], [1, 8, -7], [1, 8, 17], [1, 15, 0], [1, 15, 10], [1, 16, 5], [4, -9, 1], [4, -9, 9], [4, -1, -7], [4, -1, 17], [4, 7, -7], [4, 7, 17], [4, 15, 1], [4, 15, 9], [5, -9, 2], [5, -9, 8], [5, 0, -7], [5, 0, 17], [5, 6, -7], [5, 6, 17], [5, 15, 2], [5, 15, 8], [6, -9, 5], [6, 3, -7], [6, 3, 17], [6, 15, 5], [13, -2, 5], [13, -1, 2], [13, -1, 8], [13, 0, 1], [13, 0, 9], [13, 3, 0], [13, 3, 10], [13, 6, 1], [13, 6, 9], [13, 7, 2], [13, 7, 8], [13, 8, 5], [14, 3, 5]];
eqS := Equation(sphere(S, (x - 1)^2 + (y - 3)^2 + (z - 5)^2 - 169 = 0, [x, y, z], 'centername' = T));
k := [seq](sort(Equation(TangentPlane(P, S, point(A, pt[])), [x, y, z])), pt in L);
seq([L[i], k[i]], i = 1 .. nops(L));


I get

With each equation has the form a*x  + b*y + c*x + d=0, how can I get in the form igcd(a,b,c,d) = 1 and a >0. If a = 0, then b>0; If b = 0, then c>0. 

PS. I use this expr := sort(primpart(3*x + 6*y + 12));
expr*signum(lcoeff(expr)) = 0;

But I do not know use it in the seq k

Page 1 of 1