Solving Mathematica Problems with FindRoot - Claire

  • Context: Mathematica 
  • Thread starter Thread starter babygrace9
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary
SUMMARY

The discussion centers on using Mathematica's FindRoot function to solve for the variable y in the equation y/(Exp[y] - 1) = Log[1+x]/x, given a specific value of x. Claire initially struggles to create a function F[x] that allows for dynamic input of x without preassigning its value. The solution provided is to define the function as F[x_] := y /. FindRoot[y/(Exp[y] - 1) == Log[1+x]/x, {y, 1}], which successfully enables the desired functionality.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of the FindRoot function in Mathematica
  • Basic knowledge of exponential and logarithmic functions
  • Ability to define and use functions in Mathematica
NEXT STEPS
  • Explore advanced features of Mathematica's FindRoot function
  • Learn about defining and using functions in Mathematica
  • Investigate error handling in Mathematica for dynamic inputs
  • Study numerical methods for solving equations in Mathematica
USEFUL FOR

Mathematica users, mathematicians, and anyone involved in numerical analysis or solving equations programmatically.

babygrace9
Messages
2
Reaction score
0
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
 
Physics news on Phys.org
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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K