Need Help with Fomula

Working on a App to calculate Sub Ohms and struggling with the way of converting this formula to something unity can work with

This is the equation
1/Rt = 1/R1 + 1/R2 + 1/R3

Hear is what i got so far any help would be amazing.

        Svc = SvcToggle.isOn;
        Dvc = DvcToggle.isOn;
        NumSubs = int.Parse(SubNum.text);
        Ohm = float.Parse(SubOhm.text);

        ParResultsTxt = ParResults.ToString("F2");
        SeriResultsTxt = SeriResults.ToString("F2");

        ParOut.text = ParResultsTxt;
        SeriOut.text = SeriResultsTxt;

        if (NumSubs <= 1 && Svc == true) {
            ParOut.text = ("Na");
       
        }

        if (Svc == true) {
            SeriResults = Ohm * NumSubs;
            ParResults = (1 / Ohm) + (1 / Ohm);
            ParResultsText = 1 / ParResults;


                }

Is this some kind of Taylor series approximation? If so, iterate it as far as you need to and sum the terms as normal.

If not, I don’t see anything in the code clearly corresponding to what you call your equation.

There is

@brenton5055 you may want to put these terms into for loop, providing set of resistance values in array, or list.
Sum up result, then do whatever needed outside the loop.

Oh I see what this is, just series and parallel resistances in an electrical circuit… Didn’t at first see that from “Ser” and “Par”… that’s why it’s always best to write it all out, like SeriesResistances and ParallelResistances.

Series resistance is just the sum, so iterate the collection of resistances and sum them up.

Parallel resistance is the inverse of the sum of the inverses of the resistances.

float[] Resistances; // fill this array out however you like

// series
float seriesResistance = 0;

foreach( var resistance in Resistances)
{
  seriesResistance += resistance;
}

// done... seriesResistance is the answer

// parallel
float sumOfInverses = 0;

// tally up their inverses
foreach( var resistance in Resistances)
{
  sumOfInverses += 1.0f / resistance;
}

// invert the results
float parallelResistance = 1.0f / sumOfInverses;

// done ... parallelResistance is the answer

Reference: https://www.electronics-tutorials.ws/resistor/res_4.html

In other news, Heisenberg, Schrodinger and Ohm get pulled over by a cop…

But I’m sure you’re all familiar with THAT story.

1 Like