• Welcome to the new Internet Infidels Discussion Board, formerly Talk Freethought.

Numerical-Iterative Solutions

steve_bank

Diabetic retinopathy and poor eyesight. Typos ...
Joined
Nov 9, 2017
Messages
13,779
Location
seattle
Basic Beliefs
secular-skeptic
The Max Power Transform Theorem is an important one in circuit.

Connect a battery v across two resistors in series r1 and r2. Given r1 what value of r2 mxizes the power transferred to r2?

The circuit equation is
PowerR2 = ((v/(r1 + r2))^2)*r2 in watts. Take the 1st derivative, set to 0, and solve.

The 1st 2nd derivative min max test

Derivation of the proof.

A numerical solution. Numerically take the derivatives and evaluate.

Code:
REM Max Power

option explicit
Sub Main

dim r2max, dr, r1, amps, r ,v,val  as double
dim N,i,j, flag, index  as integer
r1 = 1.
v = 1.
r2max = 5.
dr = .1
N = r2max/dr
dim pr2(N),dpr2_1(N),dpr2_2(N),r2(N) as double
r = 0.

for i = 1 to N
    r2(i) = r
    r = r + dr
    amps = v/(r1 + r2(i))  ' current
    pr2(i) = (amps^2)*r2(i) 'r2 power watts
next i

flag = 0
for i = 1 to N-1
    dpr2_1(i) = (pr2(i+1) - pr2(i))/dr '1st derivative
    ' find 1st derivative zero crossing
    if flag = 0 AND dpr2_1(i)<= 0. then
       flag = 1
       index = i
    end if
next i

for i = 1 to N-2
    dpr2_2(i) = (dpr2_1(i+1) - dpr2_2(i))/dr '2nd derivative
next i

print  r2(index)
select case  dpr2_2(index)
    case > 0.: msgbox "MINIMUN"
    case = 0:  msgbox "NO SOLUTION"
    case < 0.: msgbox "MAXIMUM"
end select

dim Doc As Object
dim cell as object
Dim Sheet As Object
Doc = ThisComponent
Sheet = Doc.Sheets (0)

for j = 1 to n-2
     Cell = Sheet.getCellByPosition(0,j)
    Cell.Value = 0.
     Cell.Value = r2(j)  
     Cell = Sheet.getCellByPosition(1,j)
    Cell.Value = 0.
    Cell.Value = dpr2_1(j)
    Cell = Sheet.getCellByPosition(2,j)
    Cell.Value = 0.
     Cell.Value = dpr2_2(j)          
next j

msgbox("done")
End Sub
 
Back
Top Bottom