# Math Puzzle...

• posted

Math Puzzle...

How do you evaluate this function:

LIMIT (0, F(x), 120)

I know the answer. I just want to see what other people think. ...Jim Thompson

```--
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      | ```
• posted

Since when is some random SPICE thing math? ;)

Software is entirely arbitrary, so if one hasn't used it before, HCLIU.

Cheers

Phil Hobbs

```--
Dr Philip C D Hobbs
Principal Consultant ```
• posted

What it says. It clamps.

Note that VA and VB are identical.

I wonder if equations are pre-compiled or interpreted. They do slow things down.

• posted

Whats F(x) ;)

If it's = x, then the limit as x goes from 0 to 120 is 120. I gather that this is what is implied by the equation.

But I could be wrong. I'm used to seeing more defined functons eg; f(x)=4x^2+3x+2

Cheers

• posted

That's what I said. I'm trying to figure out how you felt that calculates average power.

...Jim Thompson

```--
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      | ```
• posted

looks like a bug.

having never encountered it in detail before I'd expect limit(a,b,c) to do ac : c else : a so LIMIT (0, F(x), 120) F(X) > 0 : F(x) else : 0

```--
?? 100% natural

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---```
• posted

If 0 < F(x) < 120 : F(x)

If F(x) < 0 : 0

If F(x) > 120 : 120

How Larkin parleyed that into calculating average power I have no clue. ...Jim Thompson

```--
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      | ```
• posted

Where did you say that? Not in this thread. You just did your usual content-free dancing around.

I'm trying to figure out how you felt that

I calculated realtime efficiency as a graphable voltage, 100 * Pout/Pin, then clamped the result to between 0 and 100 (or in another situation, 0 and 120 just to see the overshoot). The clamp is there because sometimes I'd get absurd picosecond startup transient spikes, like -14 teravolts, division by zero sorts of things, which would blow through my lowpass filter. LT Spice would scale all the voltage graphs accordingly.

Adding 1 milliwatt to Pin fixed the math excursion, but LIMIT is better. LIMIT is interesting, the "intermediate value" function. It's easy to remember because you can enter the three arguments in any order.

Iout and Iin were lowpass filtered to make the current and power values realistic and reasonably graphable. The efficiency result was filtered a bit too, to get smooth graph lines. All that adds a little time lag, not important to me. I could use higher order filters if the lag bothers me, but it would clutter up my schematic.

You got a problem with any of that?

• posted

In LT Spice, LIMIT (x,y,z) returns the intermediate, "middle" value of the three args. They can be placed in any order. If two are constants and one is F, it returns F clamped to the limits declared by the two constants. It's handy to keep values from getting crazy, which they sometimes do in Spice.

• posted

Yeah, that seems to happen a lot lately, the part about having no clue. Most people would ask for clarification; not you.

• posted

well: that's what the docuentation which I could find said would happen.

apparently limit really computes the median of it's three inputs and returns that.

```--
?? 100% natural```
• posted

Cannot be evaluated as F(x) is unknown.

• posted

Even though I've known of you for years, you never fail to astonish me with your stupidity. ...Jim Thompson

```--
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      | ```
• posted

Still zero content. You've lost it, you nasty old git.

• posted

So tell us, oh great master! ...Jim Thompson

```--
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      | ```
• posted

Nope, NOT precisely median, unless you mean a vague term "middle" value.

"In statistics and probability theory, the median is the numerical value separating the higher half of a data sample, a population, or a probability distribution, from the lower half."

From PSPCREF (it's PSpice, you know :-)...

LIMIT(x,min,max) result is min if x < min, max if x > max, and x otherwise

limit(x,y,z) Intermediate value of x, y, and z

which is what I said above. So it clips data.

Larkin uses it to discard data he doesn't like...

"It's handy to keep values from getting crazy, which they sometimes do in Spice."

I'm still waiting for an answer from Larkin of how that computes efficiency, but I'm not holding my breath. ...Jim Thompson

```--
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      | ```
• posted

Produce some facts instead of name-calling. You're a fraud. And NOLA white trash to boot ;-) ...Jim Thompson

```--
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      | ```
• posted

For calculating such things as "efficiency", easy in PSpice (AVGX in the Probe viewer), difficult in LTspice, I got the following information from Helmut (moderator of the LTspice list)...

Hello Jim.

Unfortunately it's not possible to directly define a formula with integration in the waveform viewer. One has to make a Bv-source in the schematic or netlist.

.param d=100u .func avgx(x,d) {(idt(x)-delay(idt(x),d))/d}

BV1 avgout 0 V=avgx(V(out),d)

BV2 avg37 0 V=avgx(V(37),d)

By the way you don't need a Bv-symbol. You could directly add these SPICE-lines from above to your schematic. You will need one B-device SPICE-line for every item you want to average.

I tried an example and found it's necessary to define a small max time step in .TRAN and to switch off data compression for best results.

.options plotwinsize=0 ; data compression off

The text after ';' is only comment.

Best regards, Helmut ...Jim Thompson

```--
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      | ```
• posted

*if* F(x) has a uniform distribution, don't you get average? or it F(x) is at least symmetrical about the average, too.
• posted

F(x) is actually F(t)... it's moving all the time in the simulation. ...Jim Thompson

```--
| James E.Thompson                                 |    mens     |
| Analog Innovations                               |     et      | ```

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.