I'm doing an exercise of integral calculus. The integral is $\int \dfrac{dx}{4-x^2}$
. This integral can be solved doing $x = 2\sin\,\alpha$
, and its solution is $\dfrac{1}{2}\ln\,|\sec\,\alpha + \tan\,\alpha|+C$
. I need to draw a rectangle triangle to avoid doing all the tedious maths, trying to find $\sec\,\alpha$
and $\tan\,\alpha$
in terms of $x$
. In the image is what I'm trying to draw.
6 Answers
With tkz-euclide
:
\documentclass[border=5mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=.8]
\tkzInit[xmax=5,ymax=3] %\tkzClip[space=.5]
\tkzDefPoint(0,0){A} \tkzDefPoint(4,0){B}
\tkzDrawTriangle[pythagore](A,B)
\tkzGetPoint{C}
\tkzMarkRightAngle(A,B,C)
\tkzDrawPoints(A,B,C)
\tkzLabelPoints[below](A,B)
\tkzLabelPoints[above](C)
\tkzLabelSegment[below,font=\footnotesize](A,B){$\sqrt{4 - x^2}$}
\tkzLabelSegment[above,font=\footnotesize](A,C){$2$}
\tkzLabelSegment[right,font=\footnotesize](B,C){$x$}
\tkzMarkAngle[fill= blue!40,size=1.4cm,opacity=.5](B,A,C)
\tkzLabelAngle[pos=0.8](B,A,C){$\alpha$}
\end{tikzpicture}
\end{document}
An attempt with MetaPost, in LuaLaTeX.
Given a real x
(supposed to be greater than 0 and lower than 2), it uses the Pythagorean subtraction (built in MetaPost) to compute the length of the other side adjacent to the angle.
\documentclass[border=2bp]{standalone}
\usepackage{luamplib}
\mplibtextextlabel{enable}
\mplibsetformat{metafun}
\begin{document}
\begin{mplibcode}
numeric u; u = 2.5cm;
beginfig(1);
x = 1; y = 2 +-+ x; % Pythagorean subtraction
pair A, B, C; A = origin; B = (u*y, 0); C = (0, u*x);
label.bot("$\sqrt{4-x^2}$", .5[A,B]);
label.lft("$x$", .5[A,C]);
label.urt("$2$", .5[B,C]);
draw ((1, 0) -- (1, 1) -- (0, 1)) scaled 2mm; % mark right angle
path angle_mark;
angle_mark = anglebetween(B--A, B--C, "\alpha"); % angle \alpha
fill B -- angle_mark -- cycle withcolor .8white;
draw A -- B -- C -- cycle;
draw angle_mark;
endfig;
\end{mplibcode}
\end{document}
Output with x = 1
:
With x = 0.5
:
With x = 1.5
:
Here is a TikZ version:
\documentclass[border=5mm,tikz]{standalone}
\usepackage{mwe}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=2]
\draw(0,0)--node[below]{$\sqrt{4-x^2}$} (1.7,0)
--node[above]{$2$}(0,1)
--node[left]{$x$}(0,0);
\draw[very thin,<->](1.4,0) arc [start angle=180,end angle=150, radius=0.3];
\node at (1.3,0.1){$\alpha$};
\end{tikzpicture}
\end{document}
Andrew's solution, but a bit more symbolic
\documentclass[border=5mm,tikz]{standalone}
\usetikzlibrary{angles,arrows.meta}
\begin{document}
\begin{tikzpicture}[scale=2]
\coordinate (A) at (0,0);
\coordinate (B) at (0,1);
\coordinate (C) at (1.7,0);
\draw (A) -- node[auto] {$x$}
(B) -- node[auto] {$2$}
(C) -- node[auto] {$\sqrt{4 - x^2}$}
cycle;
\draw pic[draw,<->,angle radius=1cm,pic text=$\alpha$,angle eccentricity=1.2] {angle = B--C--A};
\end{tikzpicture}
\end{document}
If you want to consider using pstricks
, this is a short code for your figure:
\documentclass[pdf]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pst-node}
\begin{document}
\footnotesize
\psset{shortput=nab, arrows=c-c, linearc = 0.005}%
\begin{psmatrix}[colsep=3.8cm, rowsep=1.8cm]
[name = A]\\
[name = B] & [name = C]
\pspolygon(A)(B)(C)
\psset{linewidth=0pt}
\ncline{A}{C}^{$2$}
\ncline{A}{B}\nbput{$x$}
\ncline{B}{C}_{$\sqrt{4-x^2}$}
\end{psmatrix}
\end{document}
-
-
1Once more, I forgot tocheck what my editor displays! Thanks for pointing it.– BernardMar 29, 2015 at 3:01
A PSTricks solution:
\documentclass{article}
\usepackage{pst-eucl}
\usepackage{xfp}
%%% parameters
% 0 < \side < 2
\def\side{1}
% \scale > 0
\def\scale{3}
\begin{document}
\begin{pspicture}[unit = \scale]%
(-0.35,-0.5)(\fpeval{\scale*sqrt(4-\side^2)},\fpeval{\scale*\side})
\pnodes{P}(0,0)(0,0)(0,\side)(\fpeval{sqrt(4-\side^2)},0)
\pspolygon(P1)(P2)(P3)
\pstMarkAngle[MarkAngleRadius = 0.2, LabelSep = 0.3]{P2}{P3}{P1}{$\alpha$}
\pstRightAngle[RightAngleSize = 0.1]{P3}{P1}{P2}
\psset{linestyle = none, offset = 7pt}
\pcline(P2)(P3)
\ncput{$2$}
\pcline(P1)(P2)
\ncput{$x$}
\pcline[offset = 9pt](P3)(P1)
\ncput{$\sqrt{4 - x^{2}}$}
\end{pspicture}
\end{document}
All you have to do is change the values of the parameters and the drawing will be adjusted accordingly.
\documentclass{...}
and ending with\end{document}
.\,
at all in that code. The thin spaces are added automatically by TeX.