Testwiki:Reference desk/Archives/Mathematics/2025 January 19

From testwiki
Revision as of 01:17, 3 February 2025 by imported>Scsbot (edited by robot: archiving January 19)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:Error:not substituted

{| width = "100%"

|- ! colspan="3" align="center" | Mathematics desk |- ! width="20%" align="left" | < January 18 ! width="25%" align="center"|<< Dec | January | Feb >> ! width="20%" align="right" |Current desk > |}

Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


January 19

Looking for a function like y=1/x with adjustable corner curve

I'm trying to figure out how to make a function that passes through (1,1) like y=1/x (I'm interested only in x>0), but lets me adjust the sharpness of that "corner" at (1,1), thereby increasing or decreasing the tail thickness of the curve while still passing through (1,1), with the tails remaining between 0<y<1 and 0<x<1, and the slope at (1,1) remaining -1.

My application for this is to create metaballs that can maintain a reasonably small radius while having a blobby connection to other metaballs at long distances. I've been experimenting with Desmos to come up with such a function but haven't hit on anything yet. ~Anachronist (talk) 09:11, 19 January 2025 (UTC)

The usual equation for a hyperbola symmetric about the y axis passing through (a, 0) would be Template:Math so if you want to rotate it by π/4 I guess it would be Template:Math or something like that? Alpha3031 (tc) 14:28, 19 January 2025 (UTC)
Thank you. Yes I tried something like that but while I could fix the knee of the curve in one place, I couldn't keep the asymptotes 90° apart at the same time and adjust the sharpness of the knee. ~Anachronist (talk) 17:32, 19 January 2025 (UTC)
Oh, right, if you want right hyperbolas only then you'd need to hold the eccentricity constant as well at Template:Sqrt which means they're all the same shape and you're just rescaling it by a factor. The easiest equation for that is probably Template:Sfrac = 1 (or equivalently, y = A/x) which has a vertex at (Template:Sqrt, Template:Sqrt). Translating (Template:Sqrt, Template:Sqrt) to (1, 1) would make the equation Template:Math. Alpha3031 (tc) 01:48, 20 January 2025 (UTC)
Yes, that holds the knee at (1,1) but it also moves the asymptotes so that the positive side of the function no longer approaches the axis, but instead approaches a constant 1a. I did finally come up with something (see below) but when applying it to metaballs, it didn't have the effect I had hoped for. ~Anachronist (talk) 23:21, 20 January 2025 (UTC)
I would start from 1/x but use a varying exponent. 1/x is x^-1, i.e. with an exponent of minus one. Larger negative exponents will I think do as you describe. X ^ -2 or 1/x^2 will give a twice as steep/sharp slope at (1, 1) and go to zero more rapidly. You can try other values, including non-integer values, for the exponent. --2A04:4A43:909F:F990:5C10:A535:8952:E94D (talk) 15:53, 19 January 2025 (UTC)
Well, that's the first thing I tried, but I need the slope at (1,1) to be -1 always. Forgot to mention that; I'll correct it above. Varying the exponent doesn't give me that, it moves the knee of the curve off (1,1). ~Anachronist (talk) 17:27, 19 January 2025 (UTC)
If your threshold is set to 1, the precise function values for x<1 are immaterial, as long as they are at least as large as the threshold. So only the shape of the tail for x>1 is relevant. To get long-distance connections, this tail should be fat.
The notion of "knee" is not very useful IMO. As α0, the fatness of the tail of f(x)=xα increases. The slope of the graph of f(x) at x=1 equals f(1)=α, so when α approaches 0 the graph becomes increasingly horizontal in that neighbourhood, ultimately just below y=1. A side effect of fat tails is that two blobs, approaching each other, will start sprouting "feelers" towards each other well before these turn into a connection, and more so with a shallow slope. I suppose this is undesirable. It is possible to keep a steeper slope like 1 while having a fat tail, but then a more intricate function definition will be needed.
Our article mentions the criterion function imetaballi(x,y,z). Consider two blobs A and B that are not far apart, but too far to have a connection. Now, if a third blob moves toward the area in the middle between A and B, its contribution to the criterion function may cause it to locally exceed the threshold. This is especially likely when you have fat tails. If this is unwanted, a better criterion may be
maxij(metaballi(x,y,z)+metaballj(x,y,z))threshold.
Can you reveal at which distance (between their centres) two blobs should become connected? Then we can (perhaps) give a better response. Even better, a series of sketches of blobs coming increasingly closer and becoming distended before mating. Also, can you control the criterion function or only the threshold and individual metaball functions?
 --Lambiam 17:51, 19 January 2025 (UTC)
Because I'm writing the code myself (this is an OpenSCAD project), I have control over everything, so I can make any criterion function with any number of inputs. I already completed the marching cube isosurface algorithm and it's working well. Here's an example of metaballs I made, and an example of a manifold thick gyroid surface, which I used to test my isosurface module.
The notion of the "knee" is necessary to establish a threshold higher than 1 that still maintains a reasonable ball radius without clipping it to some minimum value, while at the same time having a fat tail at x>1 that allows two balls to combine at long distances without the ball radius growing too much. The function f(x)=xa causes the diameter of the ball to shrink too far when isolated from other balls, and grow too fast when in proximity to other balls. That's why I'm looking for a function that would be, at the extreme, nearly vertical at x<1 and nearly horizontal at x>1 (both legs connected by a small-radius knee), with each leg approaching the axis at the same rate.
Picture two balls, say with an approximate radius of 10 (give or take), 70 units apart, and connected by a long tendril, like two wads of bubblegum stretched far apart after being stuck together. That's kind of what I'm going for. ~Anachronist (talk) 23:38, 19 January 2025 (UTC)
The x-scale and y-scale have no a priori established relationship. All ascending exponential curves (y=aexp(λx) with positive a and λ) are similar. You can define the "knee" of a curve as the point where the angle of the slope equals 45, but where this is depends on the ratio of the x- and y-scale, which is why I doubt the usefulness of the concept without an established relationship between these scales. You can kind of create a relationship by equating the threshold value (measured on the y-scale) with the radius of a typical solitary ball (measured on the x-scale). Then a slope of 1 means that a 1% increase of the metaball function means a 1% increase in the radius of the ball.
How wide do you envisage the diameter of the tube at its thinnest? What should we see when these balls are 50 or 100 units apart? And what would you use as the threshold?  --Lambiam 01:51, 20 January 2025 (UTC)
I don't have any preconceived notions of the width of the tube at its thinnest, and I expect the balls to separate and join like regular metaballs, just at bigger distances. The answers depend on my experimentation now that I have finally found a function that does what I want:
f(x)=(a(max(x,d)d))1a, where d=11a
(on Desmos here). The vertical asymptote is always at x=d and stays in the range 0<x<1, the horizontal asymptote is always y=0, the function always passes through (1,1) and the slope at (1,1) is always -1. Increasing a sharpens the corner and thickens the tail. I didn't expect the vertical asymptote would need to move but it should work well for constraining the minimum radius of the metaball. ~Anachronist (talk) 02:45, 20 January 2025 (UTC)
...and, in practice, it turns out not much different than the usual metaball functions. Oh well. ~Anachronist (talk) 03:04, 20 January 2025 (UTC)
When I wrote "at its thinnest", I meant for the case of two balls with a radius of 10 units having their centres 70 units apart. Is it more like 5 units or more like half a unit?  --Lambiam 10:50, 20 January 2025 (UTC)
It doesn't matter to me as long as the connection is thinner than the ball on each end, and the connection exists. ~Anachronist (talk) 23:14, 20 January 2025 (UTC)