Mathematica Problem, please help me!

  • Mathematica
  • Thread starter babygrace9
  • Start date

Main Question or Discussion Point

I've been having this problem for about a week now, and would love to hear from anyone who is familiar with Mathematica and can offer some insight:

I think the basic concept is simple. I have two variables, let's call them x and y, related in the following way:
y/(Exp[y] -1) = Log[1+x]/x

I know the value of x, and I would like to know the value of y. Thus I can employ FindRoot:
FindRoot[y/(Exp[y] -1) == Log[1+x]/x, {y, 1}]

If I have specified the value of x already, i get a good response from FindRoot, for example
In: x = -.6
FindRoot[y/(Exp[y] -1) == Log[1+x]/x, {y, 1}]
Out: {y -> -.916291}

However, what I really want is a function called F[x], such that when I feed any value of x to it, it will apply FindRoot and give the numerical value of y. I have tried the following equation:

F[x] := FindRoot[y/(Exp[y] -1) == Log[1+x]/x, {y, 1}]

and the equation
F[x] := x /. FindRoot[y/(Exp[y] -1) == Log[1+x]/x, {y, 1}]

and also the equation
F[x] /. FindRoot[y/(Exp[y] -1) == Log[1+x]/x, {y, 1}]

All of these give me an error, unless I have "preassigned" a numerical value of x. But I don't want to have a preassigned value of x, I want to be able to enter any value of x that I choose into F[x] and have FindRoot spit out a numerical value for y. Is this possible? Can anyone better at Mathematica than I am give me some advice? I would be forever in your debt, this has been driving me crazy.

Thanks,
Claire
 

Answers and Replies

Welcome to PF

Write F[x_] instead.


Code:
F[x_]:=y/.FindRoot[y/(Exp[y] -1) == Log[1+x]/x, {y, 1}];
 
Last edited:
Ah, thank you so much, I really appreciate it.
 

Related Threads for: Mathematica Problem, please help me!

Replies
2
Views
2K
Replies
3
Views
1K
Replies
1
Views
3K
Replies
1
Views
3K
Replies
1
Views
3K
Replies
0
Views
2K
Top