Aakash Agrahari - Bca104
Aakash Agrahari - Bca104
AND)
2. Octal Number System
The octal number system is base 8, using digits from 0 to
7. Octal was commonly used in early computer systems,
especially before hexadecimal became more popular, as
it is more compact than binary for represen ng data, but
s ll easier to convert from binary.
Usage of Octal in Programming:
Compact Representa on: Octal was widely used to
to another.
o Rota on: Rota ng an object around an axis.
object.
o Shearing: Skewing the shape of an object along
o A → B: 10
o A → C: 20
o B → C: 5
o B → D: 10
o C → D: 5
o D → E: 2
o C → E: 15
A = 0, B = ∞, C = ∞, D = ∞, E = ∞
Current node: A
2. Visit A:
o A → B: Distance from A to B = 0 + 10 = 10 →
divided)
f(n)=nf(n) = n (The work done outside the recursive
1. Newton-Raphson Method
The Newton-Raphson method is an itera ve numerical
technique used to find the roots (or solu ons) of a real-
valued func on. It is par cularly effec ve for finding
solu ons to nonlinear equa ons of the form:
f(x)=0f(x) = 0
The method is based on the idea of linear approxima on.
Star ng with an ini al guess for the root, the Newton-
Raphson method uses the deriva ve of the func on to
refine the guess itera vely un l it converges to the actual
root.
Mathema cal Formula on:
The Newton-Raphson method updates an ini al guess
x0x_0 using the following itera on formula:
xn+1=xn−f(xn)f′(xn)x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}
Where:
xnx_n is the current approxima on of the root.
Convergence:
The method converges quickly when the ini al guess
2. Bisec on Method
The Bisec on method is another numerical technique for
solving nonlinear equa ons. It is a bracke ng method
that works by repeatedly narrowing the range within
which a root lies. It requires two ini al guesses aa and bb
such that f(a)f(a) and f(b)f(b) have opposite signs (i.e., the
root lies between aa and bb by the Intermediate Value
Theorem).
Mathema cal Formula on:
The Bisec on method itera vely divides the interval
[a,b][a, b] into two halves and selects the subinterval
where the root must lie. The process is as follows:
1. Compute the midpoint m=a+b2m = \frac{a + b}{2}.
2. If f(m)=0f(m) = 0, then mm is the root.
3. Otherwise, if f(a) f(m)<0f(a) \cdot f(m) < 0, then the
root lies in the interval [a,m][a, m]. Set b=mb = m.
4. If f(b) f(m)<0f(b) \cdot f(m) < 0, then the root lies in
the interval [m,b][m, b]. Set a=ma = m.
5. Repeat the process un l the interval [a,b][a, b] is
sufficiently small, indica ng that mm is an accurate
approxima on of the root.
Example: Solving x2−2=0x^2 - 2 = 0 (Finding 2\sqrt{2})
For the equa on f(x)=x2−2f(x) = x^2 - 2, we want to find
xx such that f(x)=0f(x) = 0. Start with an interval, say a=1a
= 1 and b=2b = 2.
1. Calculate the midpoint: m=1+22=1.5m = \frac{1 +
2}{2} = 1.5
2. Evaluate the func on at mm:
f(1.5)=(1.5)2−2=0.25f(1.5) = (1.5)^2 - 2 = 0.25 Since
f(1) f(1.5)<0f(1) \cdot f(1.5) < 0, the root lies
between 11 and 1.51.5. So, update b=1.5b = 1.5.
3. Repeat the process un l the interval becomes
sufficiently small, yielding an approxima on for
2\sqrt{2}.
Applica ons of Bisec on Method:
Root-Finding in Mathema cs: It is commonly used
to find the root of func ons that are con nuous and
change sign over the interval.
Signal Processing: The method is used in signal
Conclusion
Numerical methods like the Newton-Raphson method
and the Bisec on method are essen al tools in solving
computa onal problems that involve nonlinear
equa ons, op miza on, and complex systems. These
methods provide approximate solu ons to problems
where analy cal solu ons are not available or are too
difficult to compute. By itera ng on ini al guesses or
narrowing intervals, these methods converge to the
correct solu on with a desired level of accuracy.
Newton-Raphson is efficient and o en converges
(45), AB (14).
3. Repeat the process:
o Combine C (12) and D (13) to create a new node
A → 000
B → 001
A → 000
C → 01
The compressed data is:
000 000 001 000 01
This is a more efficient representa on of the data
because it uses fewer bits than if we had used a fixed-
length encoding (e.g., using 8 bits per character).
Applica ons of Huffman Coding
Text Compression: Huffman coding is widely used in
harmony in music.
o Speech Processing: Iden fying different
pa erns in sound.
o Vibra on Analysis: In mechanical engineering,
Conclusion
Fourier analysis is an essen al tool in signal processing
and data compression. By transforming signals into the
frequency domain, it allows for a be er understanding of
their structure, enabling efficient processing, filtering,
and compression. In signal processing, it aids in
frequency analysis, noise removal, and modula on, while
in data compression, it underpins various algorithms that
reduce the size of audio, image, and video data without
sacrificing quality. Whether for enhancing
communica on systems or op mizing storage and
transmission, Fourier analysis plays a vital role in modern
technology.
Ans-8:- Boolean Algebra: Defini on and Concepts
Boolean Algebra is a branch of mathema cs that deals
with binary variables and logical opera ons. It is used
extensively in the design and analysis of digital circuits
and systems. Boolean algebra simplifies the manipula on
of logical statements and is essen al in computer
science, electrical engineering, and digital logic design.
The basic opera ons in Boolean algebra are:
1. AND ( ): This opera on results in 1 if both operands
are 1, and 0 otherwise.
2. OR (+): This opera on results in 1 if at least one
operand is 1, and 0 only if both operands are 0.
3. NOT (‾): This opera on inverts the value of the
operand. If the operand is 1, it becomes 0, and if the
operand is 0, it becomes 1.
Basic Boolean Algebra Laws
1. Iden ty Law:
o A 1=AA \cdot 1 = A
o A+0=AA + 0 = A
2. Null Law:
o A 0=0A \cdot 0 = 0
o A+1=1A + 1 = 1
3. Domina on Law:
o A A=AA \cdot A = A
o A+A=AA + A = A
4. Complement Law:
o A A′=0A \cdot A' = 0
o A+A′=1A + A' = 1
5. Distribu ve Law:
o A (B+C)=A B+A CA \cdot (B + C) = A \cdot B + A
\cdot C
o A+(B C)=(A+B) (A+C)A + (B \cdot C) = (A + B)
\cdot (A + C)
6. De Morgan’s Theorems:
o (A B)′=A′+B′(A \cdot B)' = A' + B'
ϕ(n)=(p−1)(q−1)\phi(n) = (p-1)(q-1).
o Choose an integer ee such that ee is coprime
# Es mate Pi
pi_es mate = 4 * inside_circle / num_points
print(f"Es mated Pi: {pi_es mate}")
Applica ons of Monte Carlo Simula ons
1. Risk Assessment and Financial Modeling: Monte
Carlo simula ons are frequently used in finance to
model the poten al future outcomes of investments,
pricing op ons, and assessing risk. It helps in
understanding the range of possible returns and
es ma ng the probability of losses.
2. Op miza on: In opera ons research and logis cs,
Monte Carlo methods are used for op miza on
problems where it is difficult to calculate the op mal
solu on directly. For instance, op mizing supply
chains or network designs with uncertain variables.
3. Physics: Monte Carlo methods are used to model
physical phenomena, such as par cle interac ons,
radia on transport, and fluid dynamics, where exact
analy cal solu ons are difficult.
4. Engineering: Monte Carlo simula ons are applied to
structural reliability analysis, performance
predic on, and fault analysis in engineering systems.
Conclusion
Simula on techniques, including Monte Carlo
simula ons, are invaluable tools in solving complex
computa onal problems, par cularly when dealing with
uncertainty or randomness. These techniques provide
prac cal and efficient ways to model, analyze, and
predict the behavior of systems across various fields such
as finance, engineering, physics, and healthcare. Monte
Carlo simula on, in par cular, is widely used for
es ma ng probabili es, op mizing systems, and
understanding the range of possible outcomes in
uncertain environments. By using random sampling and
sta s cal analysis, Monte Carlo provides powerful
insights into complex systems that would be difficult to
analyze through direct calcula on alone.