Delta-rational chord: Difference between revisions

Inthar (talk | contribs)
Inthar (talk | contribs)
Line 78: Line 78:


=== Partially DR ===
=== Partially DR ===
For approximating target delta signature of the form <math>+\delta_1 +? +\delta_3</math> with the chord <math>1:(1+E_1):(1+E_2):(1+E_3)</math> (where the +? is free to vary), the least-squares problem is
<math>
\displaystyle {\underset{x,y}{\text{minimize}} \sqrt{(\delta_1 x - E_1)^2 + ((\delta_1 + y)x - E_2)^2 + ((\delta_1 + y + \delta_3) x - E_3)^2 }}.
</math>
We can use SymPy to solve this:
<syntaxhighlight lang="py">
import sympy
x = sympy.Symbol('x', real=True)
y = sympy.Symbol('y', real=True)
d1 = sympy.Symbol('\\delta_{1}', real=True)
d2 = sympy.Symbol('\\delta_{2}', real=True)
d3 = sympy.Symbol('\\delta_{3}', real=True)
E1 = sympy.Symbol('E_1', real=True)
E2 = sympy.Symbol('E_2', real=True)
E3 = sympy.Symbol('E_3', real=True)
err_squared = (d1*x - E1) ** 2 + ((d1 + y)*x - E2) ** 2 + ((d1 + y + d3)*x - E3) ** 2
err_squared.expand()
err_squared_x = sympy.diff(err_squared, x)
err_squared_y = sympy.diff(err_squared, y)
sympy.nonlinsolve([err_squared_x, err_squared_y], [x, y])
</syntaxhighlight>


== DR chords in small edos ==
== DR chords in small edos ==