1

Is there a way given start, stop & duration values I can find the increment for a log10 sweep for a discrete series.

For example in the simple case of a linear sweep the next value can always be found as.

$$y_n=y_{n-1} + (y_{finish}-y_{start})\frac{\Delta t}{t_{finish}}$$

I am a bit rusty with logarithms and cant work out the similar equation for a log 10 curve, is it possible?

Hugoagogo
  • 131

1 Answers1

0

I'm not 100% sure what you're trying to do but you can approximate a logarithm using $\Delta x/x$ so that $$ \log(x+\Delta)=\log(x)+\Delta/x $$ Here is a numeric demonstration:

package main

import ( "fmt" "math" )

func main() { start := 1.0 step := 0.01 max := 1000 logs := make([]float64, max) logs[0] = 0 for i := 1; i < max; i++ { x := start + float64(i)step logs[i] = logs[i-1] + step1/x fmt.Printf("%.3f %.4f %.4f\n", x, math.Log(x), logs[i]) } }

Run it online here

If you need $\log_{10}$ then just divide by $\log(10)\approx2.3$, so increment by $\Delta/(x\times\log(10))$

Suzu Hirose
  • 11,660
  • The context was wanting to be able to setup a log sweep in a system where I don't know the current step, e.g. i in your program. And wanted to know if I could calculate the current value based on only knowing the last value, and some configuration parameters (Start,End,overall time) – Hugoagogo Aug 08 '22 at 06:11
  • @Hugoagogo I think you need to rephrase the question then. – Suzu Hirose Aug 08 '22 at 06:20
  • In writing the previous comment I realised I had made a silly mistake in the excel doc I was using to do a quick check and had set the X axis to log instead of Y. I can now see that I can use the form $y_n=y_{n-1} \times k$ would you have any tips on how I can compute k. – Hugoagogo Aug 08 '22 at 06:23
  • $k=(\frac {y_{finish}}{y_{start}})^\frac{\delta t}{t_{finish}}$ seems close but not quite right. – Hugoagogo Aug 08 '22 at 06:36