¿ªÔÆÌåÓý

Using BV exp(), log() for numerical compression ,wrong result ?


 

Hi, :


While I am thinking using a mathematical compression (limit the numerical values to a scaled range, then revert them) algorithm, I found that in the BV device, the exp(), log() (natural algorithm) couldn't work as expect, normally I wish to use the math equation, x = log ( exp(x) ) or x = exp( log(x) ), but the waveform output disappointed me, the result from BV makes the 'x ' won't be the source of the signal.


Does anyone know why ? Can it be fixed ? Do I need any bias in LTspice ? I pretty sure some tools didn't need bias.


I have uploaded a file '20181126_20181126_BV_exp_log_convert.zip' at the temp folder.


Thank you very much.


Best regards.


 

Hi, :

Please help, do you know how much powerful this will help, it could minimize the numerical value from 120dB to number '13.8155'. Which help to plot/sketch them in a single graph. Where stores much info and without distort it.

thank you very much.

---In LTspice@..., <ericsson.sunshine@...> wrote :

Hi, :


While I am thinking using a mathematical compression (limit the numerical values to a scaled range, then revert them) algorithm, I found that in the BV device, the exp(), log() (natural algorithm) couldn't work as expect, normally I wish to use the math equation, x = log ( exp(x) ) or x = exp( log(x) ), but the waveform output disappointed me, the result from BV makes the 'x ' won't be the source of the signal.


Does anyone know why ? Can it be fixed ? Do I need any bias in LTspice ? I pretty sure some tools didn't need bias.


I have uploaded a file '20181126_20181126_BV_exp_log_convert.zip' at the temp folder.


Thank you very much.


Best regards.


 

You know, if my window could tolerate a swing of 100, this method will help avoiding ruin my window. Since the swing could minimize from 1Mega to thirteen degree.
Wouldn't you like to know the answer, possible or impossible ?

Or still the old problem, LTspice could see the complex (imaginary) part. Which does exist in the real world.

Best regards.

---In LTspice@..., <ericsson.sunshine@...> wrote :

Hi, :

Please help, do you know how much powerful this will help, it could minimize the numerical value from 120dB to number '13.8155'. Which help to plot/sketch them in a single graph. Where stores much info and without distort it.

thank you very much.

---In LTspice@..., <ericsson.sunshine@...> wrote :

Hi, :


While I am thinking using a mathematical compression (limit the numerical values to a scaled range, then revert them) algorithm, I found that in the BV device, the exp(), log() (natural algorithm) couldn't work as expect, normally I wish to use the math equation, x = log ( exp(x) ) or x = exp( log(x) ), but the waveform output disappointed me, the result from BV makes the 'x ' won't be the source of the signal.


Does anyone know why ? Can it be fixed ? Do I need any bias in LTspice ? I pretty sure some tools didn't need bias.


I have uploaded a file '20181126_20181126_BV_exp_log_convert.zip' at the temp folder.


Thank you very much.


Best regards.


 

Hello,

You have used log() from negative numbers. Normal calculators will fail in this case.

I recommend to use an IF() to workaround.

V=IF(V(x)<1e-6,0,log(V(x))

Be aware that log() is the same as ln(). log10() is the logarithm base 10.

Best regards,
Helmut


 

Hi, Helmut:

Thank you for the suggestions, but if I use the IF() as you mentioned, x couldn't be recovered as it was before compression.
But your answer seems LTspice couldn't treat the negative value of nature log very well, which normally return the complex value, eg: log(-2) =?0.6931 +? 3.1416i.
As I said, LTspice couldn't see the complex (imaginary) parts. And treat it very well, as it should be treated in the normal math world.

Though I found another solution, it's using the dc-bias in the source signal, after recovered it, eliminate the dc-bias, this could be done well, too. But I am thinking, why LTspice couldn't treat those math functions equal-footing, alternatively, some math functions are biased, while some are? "NOT SUPPORTED/PARTLY SUPPORTED". Is it fair , unfair ?

Best regards,
---In LTspice@..., <helmutsennewald@...> wrote :

Hello,

You have used log() from negative numbers. Normal calculators will fail in this case.

I recommend to use an IF() to workaround.

V=IF(V(x)<1e-6,0,log(V(x))

Be aware that log() is the same as ln(). log10() is the logarithm base 10.

Best regards,
Helmut


 

Hello,

Even log(0) is a big problem. The result be -infinity which is useless in a real circuit. That's why my suggested IF() has used a limit of 1e-6.

Best regards,
Helmut


 

ericsson.sunshine wrote:

? ? "LTspice couldn't treat the negative value of nature log very well, which normally return the complex value ..."

? ? "LTspice couldn't see the complex (imaginary) parts. And treat it very well, as it should be treated in the normal math world."

I think most people here understand this: "The natural logarithm function ln(x) is defined only for x>0.? So the natural logarithm of a negative number is undefined."? Undefined means it has no defined value when x is negative, or zero.? I think in math, this would be represented by NaN (but I might be wrong).

The "complex logarithm" is an extension to complex numbers, but it differs from an ordinary logarithm.? Perhaps you work in a math world that treats the complex logarithm as a normal logarithm function, but I think most of us engineers do not.? The logarithm functions in LTspice are not defined to be complex logarithms, therefore one should not expect them to behave as complex logarithms; they are the ordinary variety of logarithm functions, which are undefined for negative arguments.? The exponential function exp() is not the inverse of the complex logarithm function.

Maybe it would help to understand what you are trying to accomplish.? I understand that you may be interested in compressing a wide dynamic range into a smaller one; but is this for signal processing?? Waveform visualization?? Theoretical analysis of non-physical signals or entities?? (Not that I'm asking for my own sake.? But it helps to know where one is going, before making the first steps, and finding that one has stepped into a hole.)

Regards,
Andy



 

Hi, Andy:

Before your explanation, I didn't notice "complex logarithm" is a special case, maybe not supposed to be supported by any SPICE.

About the compression application, I didn't really have the complete idea, maybe it would be like the,....
For example, when someone reading a book, the edge on every page often empty, and be used to sketch some thing on, some graphs/pictures to decorate the layout of the page. They often are not the primary parts.

To analogy, if there are some main data, which typically are numerical values, and has its general scale on the range of greater than 0.01, though its format could support to very least 1e^-16, or some, such that, maybe I could merge those loged numbers secretly into the "main data", and leak .... to somewhere who concern it, without interference others who typically don't care those smaller values which is under 0.01.

Just some ignorant ideas. I didn't implement it yet.

Best regards.


---In LTspice@..., <ai.egrps@...> wrote :

ericsson.sunshine wrote:

? ? "LTspice couldn't treat the negative value of nature log very well, which normally return the complex value ..."

? ? "LTspice couldn't see the complex (imaginary) parts. And treat it very well, as it should be treated in the normal math world."

I think most people here understand this: "The natural logarithm function ln(x) is defined only for x>0.? So the natural logarithm of a negative number is undefined."? Undefined means it has no defined value when x is negative, or zero.? I think in math, this would be represented by NaN (but I might be wrong).

The "complex logarithm" is an extension to complex numbers, but it differs from an ordinary logarithm.? Perhaps you work in a math world that treats the complex logarithm as a normal logarithm function, but I think most of us engineers do not.? The logarithm functions in LTspice are not defined to be complex logarithms, therefore one should not expect them to behave as complex logarithms; they are the ordinary variety of logarithm functions, which are undefined for negative arguments.? The exponential function exp() is not the inverse of the complex logarithm function.

Maybe it would help to understand what you are trying to accomplish.? I understand that you may be interested in compressing a wide dynamic range into a smaller one; but is this for signal processing?? Waveform visualization?? Theoretical analysis of non-physical signals or entities?? (Not that I'm asking for my own sake.? But it helps to know where one is going, before making the first steps, and finding that one has stepped into a hole.)

Regards,
Andy



 

¿ªÔÆÌåÓý

I suppose you do realise that you can make one or both axes of a plot logarithmic. You can also plot, for example log(V(out) on a log axis, so get a log-log scale, using waveform arithmetic.

Best wishes
John Woodgate OOO-Own Opinions Only
J M Woodgate and Associates 
Rayleigh, Essex UK
On 2018-11-27 01:07, ericsson.sunshine@... [LTspice] wrote:

?

Hi, Andy:


Before your explanation, I didn't notice "complex logarithm" is a special case, maybe not supposed to be supported by any SPICE.

About the compression application, I didn't really have the complete idea, maybe it would be like the,....
For example, when someone reading a book, the edge on every page often empty, and be used to sketch some thing on, some graphs/pictures to decorate the layout of the page. They often are not the primary parts.

To analogy, if there are some main data, which typically are numerical values, and has its general scale on the range of greater than 0.01, though its format could support to very least 1e^-16, or some, such that, maybe I could merge those loged numbers secretly into the "main data", and leak .... to somewhere who concern it, without interference others who typically don't care those smaller values which is under 0.01.

Just some ignorant ideas. I didn't implement it yet.

Best regards.


.