Saturday, April 20, 2024

Menulis Source Code Latex

 \usepackage{verbatim} %menulis sourcecode
\usepackage{listings} %menulis sourcecode
\usepackage{xcolor}%menulis sourcecode
%---
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
%===
\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}
\lstset{style=mystyle}
%---

\begin{lstlisting}[language=python, caption=Regresi Linier HP dan Kamera]
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression

df = pd.DataFrame([[8,7],[2,3],[6,7],[4,2],[7,8],[3,3]])
df.columns = ['x', 'y']

x_train = df['x'].values[:,np.newaxis]
y_train = df['y'].values

lm = LinearRegression()
lm.fit(x_train,y_train) # fase training

print('Coefficient : ' + str(lm.coef_))
print('Intercept : ' + str(lm.intercept_))

x_test = [[170],[171]] # data yang akan diprediksi
p = lm.predict(x_test) # fase prediksi
print(p) # hasil prediksi

# prepare plot
pb = lm.predict(x_train)
dfc = pd.DataFrame({'x': df['x'],'y':pb})

plt.scatter(df['x'],df['y'])
plt.plot(dfc['x'],dfc['y'],color='red',linewidth=1)
plt.xlabel('kamera')
plt.ylabel('harga')
plt.show()
\end{lstlisting}

Wednesday, January 10, 2024

Problem Set 2.5 - Chain Rule

 16. $ y= cos^3(\frac{x^2}{1 - x}) $

$ v= \frac{x^2}{1-x}, ~ u=cos \, v, ~ y = u^3 $

$\frac{dy}{dx} = \frac{dv}{dx}. \frac{du}{dv}. \frac{dy}{du}$

$ = (\frac{(1 - x)D_x(x^2) - (x^2) D_x(1 - x)}{(1 - x)^2}). (- sin \, v).(3u^2) $

$ = \frac{(1-x)(2x) -(x^2)(-1)}{(1 - x)^2}. sin(\frac{x^2}{1 -x}). (-3 cos^2 (\frac{x^2}{1 - x}))$

$ = \frac{-3(2x - x^2)}{(1 - x)^2}cos^2(\frac{x^2}{1-x}) sin(\frac{x^2}{1 -x }) $

Sunday, January 7, 2024

Problem Set 2.4 Derivatif Trigonometri

catatan :

$ \frac{d}{dx} sin x~= cos\, x$

$ D_x (cos x)~= - sin\, x$

$ \frac{d}{dx}tanx~=sec^2 x$

$D_x (cot\, x)~=-csc\, x $

$\frac{d}{dx} sec x~=sec\, x\, tan\, x$ 

--------

$ 6. ~y = csc\, x$

$ D_x(csc \, x) = D_x \frac{1}{sin x}$

$ = \frac{sin x\, D_x(1) - (1)\, D_x(sin x)}{sin^2 x}$

$ = \frac{0 - cos\, x}{sin^2 x}~=\frac{-1}{sin x}.\frac{cos\, x}{sin\, x}~= -csc\,x \,cot\, x$


$10.~y= \frac{sin x + cos x}{tan x} $ 

$\frac{d}{dx}(\frac{sin x + cos x}{tan x})$

$=\frac{tanx\, D_x (sin x+ cos x) - (sin x+ cos x)\, D_x (tan x)}{tan^2 x}$

 $= \frac{tanx(cosx-sinx)-(sinx+cosx)sec^2 x}{tan^2x}$

$= \frac{tanx(cosx-sinx)-(sinx+cosx)sec^2 x}{\frac{sin^2x}{cos^2x}}$ 

$ = [sin x - \frac{sin^2 x}{cos x} - \frac{sin x}{cos^2 x} - \frac{1}{cos x}]  : [\frac{sin^2 x}{cos^2 x}]$

$ = [sin x - \frac{sin^2 x}{cos x} - \frac{sin x}{cos^2 x} - \frac{1}{cos x}]  [\frac{cos^2 x}{sin^2 x}]$

$ =\frac{cos^2 x}{sin x} - cos x - \frac{1}{sin x} - \frac{cos x}{sin^2 x} $




Problem Set 1.4 : Limit Involving Trigonometric Functions

$ 7.  \lim_{\theta \to 0} \frac{sin\, 3\theta}{tan \, \theta} $

$= \lim_{\theta \to 0} \frac{sin \, 3\theta}{\frac{sin \theta}{cos \theta}} $

$ = \lim_{\theta \to 0} \frac{cos\theta \, sin 3\theta}{sin \theta} $

$ = \lim_{\theta \to 0} [ \frac{sin 3\theta}{3 \theta}. 3\, cos \theta . \frac{1}{sin \theta} . \theta ] $ 

$ = 3 \lim_{\theta \to 0} [ \frac{sin 3\theta}{3\theta}. cos \theta. \frac{\theta}{sin \theta}] $

$ = 3 (1.1.1)~=~3 $


$ 8.  \lim_{\theta \to 0} \frac{tan 5\theta}{sin 2\theta} $

$ = \lim_{\theta \to 0} \frac{\frac{sin 5\theta}{cos 5\theta}}{sin 2\theta} $

$ = lim_{\theta \to 0} \frac{sin5 \theta}{ cos 5\theta \, sin 2\theta} $

$ = lim_{\theta \to 0} [\frac{sin 5\theta}{5\theta}.\frac{2\theta}{sin 2\theta}.\frac{1}{cos 5\theta}.5\theta. \frac{1}{2\theta}] $

$ = lim_{\theta \to 0} [\frac{sin 5\theta}{5\theta}.\frac{2\theta}{sin 2\theta}.\frac{1}{cos 5\theta}.\frac{5}{2}]  $

$ =  \frac{5}{2} lim_{\theta \to 0} [\frac{sin 5\theta}{5\theta}.\frac{2\theta}{sin 2\theta}.\frac{1}{cos 5\theta}] $

$ = \frac{5}{2} (1.1.1)~=~ \frac{5}{2} $

 

$9. \lim_{\theta \to 0} \frac{cot\, \pi \theta \, sin \theta}{2 sec \theta}$

$ = \lim_{\theta \to 0} \frac{\frac{cos \pi \theta}{sin \pi \theta} sin \theta}{\frac{2}{cos \theta}}$

$ = \lim_{\theta \to 0} \frac{cos \pi \theta \, sin \theta \, cos \theta}{s sin \pi \theta} $

$= \lim_{\theta \to 0} [\frac{sin \theta}{\theta}. \frac{\pi \theta}{sin \pi \theta}. \frac{1}{\pi}. \frac{cos \pi \theta \, cos \theta}{2}]$

$ = \frac{1}{2} ~\lim_{\theta \to 0}  [\frac{sin \theta}{\theta}. \frac{\pi \theta}{sin \pi \theta}. cos \pi \theta \, cos \theta ]$

$ =\frac{1}{2 \pi}(1.1.1) ~=~\frac{1}{2 \pi}$