Peter:

I replace tanh~ with un Euler approximation of  2.71828 : tanh(x)=(e^x - e^-x) / (e^x + e^-x)
I'm not sure if it's ok, but it works:

#N canvas 224 224 483 354 12;
#X obj 75 167 pow~;
#X obj 75 98 sig~ 2.71828;
#X obj 75 232 -~;
#X obj 144 140 *~ -1;
#X obj 123 167 pow~;
#X obj 108 231 +~;
#X obj 75 273 /~;
#X obj 99 46 inlet~;
#X obj 75 307 outlet~;
#X text 114 15 tanh(x)=(e^x - e^-x) / (e^x + e^-x);
#X text 201 100 euler;
#X connect 0 0 2 0;
#X connect 0 0 5 0;
#X connect 1 0 0 0;
#X connect 1 0 4 0;
#X connect 2 0 6 0;
#X connect 3 0 4 1;
#X connect 4 0 2 1;
#X connect 4 0 5 1;
#X connect 5 0 6 1;
#X connect 6 0 8 0;
#X connect 7 0 0 1;
#X connect 7 0 3 0;

Claudio.



El jue, 11 dic 2025 a las 17:31, <pd-list-request@lists.iem.at> escribió:
Send Pd-list mailing list submissions to
        pd-list@lists.iem.at

To subscribe or unsubscribe via email, send a message with subject or
body 'help' to
        pd-list-request@lists.iem.at

You can reach the person managing the list at
        pd-list-owner@lists.iem.at

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Pd-list digest..."

Today's Topics:

   1. tanh~ distortion without expr~? (Peter P.)
   2. Re: tanh~ distortion without expr~? (cyrille henry)
   3. Re: tanh~ distortion without expr~? (Peter P.)
   4. Re: tanh~ distortion without expr~? (Simon Iten)


----------------------------------------------------------------------

Message: 1
Date: Thu, 11 Dec 2025 12:01:41 +0100
From: "Peter P." <peterparker@fastmail.com>
Subject: [PD] tanh~ distortion without expr~?
To: pd-list <pd-list@lists.iem.at>
Message-ID:
        <hebj2lz6dhgl27j5az7tgohuiyfrlqwaily5ajdfbdy3rkkwzp@63oldhy2nqvh>
Content-Type: text/plain; charset=us-ascii

Hi,

is there a vanilla way to implement tanh~ distortion without using expr~?

Thanks!
P


------------------------------

Message: 2
Date: Thu, 11 Dec 2025 12:11:16 +0100
From: cyrille henry <ch@chnry.net>
Subject: [PD] Re: tanh~ distortion without expr~?
To: <pd-list@lists.iem.at>
Message-ID: <b5a68476-51f8-4699-8e47-7742778702ef@chnry.net>
Content-Type: text/plain; charset="UTF-8"; format=flowed

hello,

For a distortion, you can use f(x) = x*(27 + x²) / (27 + 9*x²) as a good enough tanh approximation. (x need to be clipped between -3 and 3)
https://www.desmos.com/calculator/dxg70xbtne?lang=fr

Cheers
C



Le 11/12/2025 à 12:01, Peter P. a écrit :
> Hi,
>
> is there a vanilla way to implement tanh~ distortion without using expr~?
>
> Thanks!
> P
>
> ---
> pd-list@lists.iem.at - the Pure Data mailinglist
> https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/WDXKOYLK6LF5XN2UFMODWREXAV2MIQR3/
>
> To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.iem.at/
>



------------------------------

Message: 3
Date: Thu, 11 Dec 2025 12:35:45 +0100
From: "Peter P." <peterparker@fastmail.com>
Subject: [PD] Re: tanh~ distortion without expr~?
To: pd-list@lists.iem.at
Message-ID:
        <lkqildo72aqe6hikykbru7ahdtl5soz3foueyr33gh62pqfjxp@gl4zvkgw7d5z>
Content-Type: text/plain; charset=iso-8859-1

Wow, quick and neat -merci bien Cyrille!
P

* cyrille henry <ch@chnry.net> [2025-12-11 12:11]:
> hello,
>
> For a distortion, you can use f(x) = x*(27 + x²) / (27 + 9*x²) as a good enough tanh approximation. (x need to be clipped between -3 and 3)
> https://www.desmos.com/calculator/dxg70xbtne?lang=fr
>
> Cheers
> C
>
>
>
> Le 11/12/2025 à 12:01, Peter P. a écrit :
> > Hi,
> >
> > is there a vanilla way to implement tanh~ distortion without using expr~?
> >
> > Thanks!
> > P
> >
> > ---
> > pd-list@lists.iem.at - the Pure Data mailinglist
> > https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/WDXKOYLK6LF5XN2UFMODWREXAV2MIQR3/
> >
> > To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list
> > UNSUBSCRIBE and account-management -> https://lists.iem.at/
> >
>
>
> ---
> pd-list@lists.iem.at - the Pure Data mailinglist
> https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/X3SMOHZDQUF73N3ZHQIUQ45NQWOR45ZR/
>
> To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.iem.at/


------------------------------

Message: 4
Date: Thu, 11 Dec 2025 17:30:53 +0100
From: Simon Iten <itensimon@gmail.com>
Subject: [PD] Re: tanh~ distortion without expr~?
To: pd-list@lists.iem.at
Message-ID: <AB58DB6B-C33F-4D36-80B2-1975F5EDFC91@gmail.com>
Content-Type: multipart/mixed;
        boundary="Apple-Mail=_5EB4542B-EC40-47A5-A970-5F89EAC38A10"

Yep, this works great!! Here is the implementation and another one, that is also quite nice…

(It is a patch to be compiled with heavy, but you get the idea)

-------------- next part --------------
A message part incompatible with plain text digests has been removed ...
Name: fx_slot1.pd
Type: application/octet-stream
Size: 21920 bytes
Desc: not available
-------------- next part --------------



> Am 11.12.2025 um 12:35 schrieb Peter P. <peterparker@fastmail.com>:
>
> Wow, quick and neat -merci bien Cyrille!
> P
>
> * cyrille henry <ch@chnry.net> [2025-12-11 12:11]:
>> hello,
>>
>> For a distortion, you can use f(x) = x*(27 + x²) / (27 + 9*x²) as a good enough tanh approximation. (x need to be clipped between -3 and 3)
>> https://www.desmos.com/calculator/dxg70xbtne?lang=fr
>>
>> Cheers
>> C
>>
>>
>>
>> Le 11/12/2025 à 12:01, Peter P. a écrit :
>>> Hi,
>>>
>>> is there a vanilla way to implement tanh~ distortion without using expr~?
>>>
>>> Thanks!
>>> P
>>>
>>> ---
>>> pd-list@lists.iem.at - the Pure Data mailinglist
>>> https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/WDXKOYLK6LF5XN2UFMODWREXAV2MIQR3/
>>>
>>> To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list
>>> UNSUBSCRIBE and account-management -> https://lists.iem.at/
>>>
>>
>>
>> ---
>> pd-list@lists.iem.at - the Pure Data mailinglist
>> https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/X3SMOHZDQUF73N3ZHQIUQ45NQWOR45ZR/
>>
>> To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list
>> UNSUBSCRIBE and account-management -> https://lists.iem.at/
>
> ---
> pd-list@lists.iem.at - the Pure Data mailinglist
> https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/QWFI7EJH5BRAA7HGHPZKWITDBWIIDPXW/
>
> To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.iem.at/
>


------------------------------

Subject: Digest Footer

_______________________________________________
Pd-list mailing list -- pd-list@lists.iem.at
To unsubscribe send an email to pd-list-leave@lists.iem.at
to manage your subscription (including un-subscription) see


------------------------------

End of Pd-list Digest, Vol 249, Issue 7
***************************************