kidos
Feb 27, 2012, 09:17 AM
Hi

IĀ“m trying to build a function which is the inverse function of f= -1/(1 exp(b)) 1/(1 exp(b-2*b*h^n)). Where b and n are constants to fit the function to a curve of data. The look of function f should be attached. So the range of the plot is f(0)=0 , f(0.5)= close to 0.5 and f(1)=1 , and simple constants to shift and fit it well. I did get something close looking to the inverse function of f but its way to complex and long, thatĀ“s exp(ln((1/2)*(b-ln(-(h h*exp(b)-exp(b))/(h h*exp(b) 1)))/b)/n). Help would be great!

kidos

ebaines
Feb 27, 2012, 09:42 AM
kidos - pelase do not cust and paste the equations from another program - as you can see some of teh important characters get dropped.

I think what you wrote is this:

f(h) = \frac {-1}{(1+ e^b)} + \frac 1 {(1 + e^{(b-2bh^n)})}

Is that right? And you want to express h as a function of f(h)?

kidos
Feb 27, 2012, 10:11 AM
Hi ebaines

Yes thatĀ“s right for f(h), and yes I want to express h as a function of f(h). Sorry for the confusing paste straight from Matlab. IĀ“ve attached the nasty complex one inverse IĀ“ve had so far, trying to get a nice simpler one.

regards

kidos

ebaines
Feb 27, 2012, 10:29 AM
Sorry, I still don't understand what you're trying to do. Specifically - why are there 'h' terms in your inverse equation? If you start with:

y=f(h) = \frac {-1} {1+e^b} + \frac 1 {(1+ e^{(b-2bh^n)})}

then I would expecty the inverse to be of the form

h = g(y)

In any event - one way to simplify your equation is to use the fact that

e^{( \frac{ ln(a)} n )} = a^{\frac 1 n}

kidos
Feb 27, 2012, 01:06 PM
Hi ebaines

Thanks for the responses. I apologize for being unclear in my explanations. The matter of case is that I had few points of results (the blue curve in my first post) and I wanted to make a function model fitting the curve of the data where h was a vector. I had tried polyfit in Matlab but that did not fit well enough so I had worked on a function which was getting close, the f(h) function but then realized that I wanted to plot the h terms on the y-axis but not on the x-axis, so I was getting my function plotting the curve mirrored through x=y line to what I wanted. It was not working to change the order of terms in my plots because the vectors values of the function fit model and results will be off (hard to explain this :S) when real values of forces and height (h) are being compared with the model values. So I was just trying to find a similar simple function as f(h) but inverse, that should fix my problem.

ebaines
Feb 27, 2012, 01:53 PM
Here's the inverse function I get:

y = \frac {-1} {1 + e^b} + \frac 1 {(1+e^{(b - 2bh^n)}

yields:

h = [\frac 1 2 - \frac 1 {2b} \ln (\frac {1+e^b}{1 + y + ye^b}-1)]^{(1/n)}

kidos
Feb 28, 2012, 03:45 AM
Hi ebaines

I have now a function which is simple and close to what I was looking for (see attached figure and function) but this function is f(0)= -Inf and f(1)= Inf , and I am trying to get f(0)=0 and f(1)=1.

ebaines
Feb 28, 2012, 05:51 AM
Perhaps a cubic would work for your purposes. You can curve fit a third order polynomial to hit the end points:

f(x) = 2x^3 - 3x^2 +2x

**EDIT A more general cubic equation that fits your needs and lets you adjust the slope of the line at x=1/2 (let's call this value 's') is:

y = Ax^3 + Bx^2 + Cx

where A = 4(1-s)
B = -3A/2
C = A/2+1

The attached figure shows how the function looks for s = 0.5 and s = 0.3.

kidos
Feb 28, 2012, 01:33 PM
Thanks for the help ebaines. Any thoughts on the GOP primaries? I am fan of Ron Paul :)