Mathematica beginner question: Function nesting

  • Mathematica
  • Thread starter physicsan
  • Start date
  • #1
2
0
Hello,
I'm quite new to Mathematica and stuck at a point, where I have searched for hours to find a solution, but there seems no way out.

Let's say we have two functions,
f1[x_,y_]=x+y
f2[x_,y_]=x*y

How can a build a function f3, which is e.g. the sum of the other functions f1 and f2, i.e. f3[x_, y_]=x+y+x*y, but without copy&paste, but with direct dependency on f1 and f2?

With f3=f1[x,y]+f2[x,y], the functional dependency on x and y is missing. I need a f3, which also has the same input arguments as f1 and f2 (namely x and y).
With f3[x_,y_]==f1[x,y]+f2[x,y] the functional dependency on the parameters is also not working.

Thanks you for your help,
I'm really desperate :(
 

Answers and Replies

  • #2
phyzguy
Science Advisor
4,741
1,671
I think that you don't understand the difference between =(immediate assignment), :=(delayed assignment) and == (test for equality). You want to use := in function assignments so that the assignment is not made until you request evaluation. Try the attached notebook - I think it does what you want.
 

Attachments

  • #3
2
0
Hi,

a thousand thanks! This is exactly what I was looking for! Sorry for my dummy question, it really seems so dummy now :s
Thank you again for your profound and amazingly fast help, you really made my day! :)
 
  • #4
phyzguy
Science Advisor
4,741
1,671
You're welcome. Glad I could help.
 

Related Threads on Mathematica beginner question: Function nesting

Replies
6
Views
7K
Replies
2
Views
3K
Replies
4
Views
4K
Replies
1
Views
5K
Replies
2
Views
4K
Replies
2
Views
3K
Replies
2
Views
1K
Replies
1
Views
2K
Replies
8
Views
4K
Top