# Exponential Impulse not working

**URL:** <https://discourse.processing.org/t/exponential-impulse-not-working/13397>\
**Category:** Coding Questions\
**Created:** [August 15, 2019, 11:41am UTC](https://discourse.processing.org/t/exponential-impulse-not-working/13397 "2019-08-15T11:41:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![clankill3r](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/clankill3r/32/1098_2.png) [@clankill3r](https://discourse.processing.org/u/clankill3r)\
**Post date:** [August 15, 2019, 11:41am UTC](https://discourse.processing.org/t/exponential-impulse-not-working/13397/1 "2019-08-15T11:41:52Z")

</div>

I’m working on this page:

> **[Inigo Quilez](https://iquilezles.org/articles/functions/)**
>
> Articles on computer graphics, math and art

And I try to get Exponential Impulse to work:

> Exponential Impulse
> 
> Great for triggering behaviours or making envelopes for music or animation, and for anything that grows fast and then slowly decays. Use **k** to control the stretching of the function. Btw, its maximum, which is 1, happens at exactly x = 1/k.

```auto
float expImpulse( float k, float x ) { 
    const float h = k*x; 
    return h*exp(1.0-h); 
}

```

![](http://www.iquilezles.org/www/articles/functions/gfx02.png)

This is what I have, but it is all being zero.

```auto

void setup() {
  size(600, 600, P2D);
}

void draw() {
  background(0);
  stroke(255);
  for (int x = 0; x < width; x++) {
    float y = expImpulse(norm(mouseX, 0, width), x);
  }
}

float expImpulse( float k, float x ) {
    float h = k*x;
    return h*exp(1.0-h);
}

```

Can someone help?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [August 15, 2019, 2:16pm UTC](https://discourse.processing.org/t/exponential-impulse-not-working/13397/2 "2019-08-15T14:16:18Z")

</div>

your code not draw or print anything,  
but with this i see something:

```auto
void draw() {
  background(0);
  stroke(255);
  for (int x = 0; x < width; x++) {
    float y = expImpulse(norm(mouseX, 0, width), x);
    point(x,height*(1-y));
  }
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 16, 2019, 11:41pm UTC](https://discourse.processing.org/t/exponential-impulse-not-working/13397/3 "2019-08-16T23:41:52Z")

</div>

Classic – forgetting to draw the point. I’ve done that. ✋

Give the input range, have to hover the mouse near the left edge to get interesting results.

---

<div class="post-metadata">

**Author:** ![clankill3r](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/clankill3r/32/1098_2.png) [@clankill3r](https://discourse.processing.org/u/clankill3r)\
**Post date:** [August 17, 2019, 2:21pm UTC](https://discourse.processing.org/t/exponential-impulse-not-working/13397/4 "2019-08-17T14:21:48Z")

</div>

> [@kll](#):
>
> your code not draw or print anything,

O damn, to much scoped in on the wrong part…
