Calculate Pure Function in Map - Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter Barioth
  • Start date Start date
  • Tags Tags
    Function Map Pure
Click For Summary
SUMMARY

The discussion focuses on calculating a pure function in Mathematica using the Map function. The user defines a function t[x_, y_] that computes the square of the sum of derivatives of two pure functions. They attempt to apply this function across a range of values for L using Map, but encounter issues with variable scoping. The solution involves understanding how to manage multiple placeholders within the Map function to avoid conflicts with the variable s.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of pure functions in Mathematica
  • Knowledge of derivatives and their notation in Mathematica
  • Basic understanding of the Map function in functional programming
NEXT STEPS
  • Learn about variable scoping in Mathematica functions
  • Explore advanced usage of the Map function in Mathematica
  • Study the implementation of pure functions and their applications in Mathematica
  • Investigate the use of ListPlot and Plot functions in Mathematica for visualizing results
USEFUL FOR

Mathematica users, particularly those interested in functional programming, derivative calculations, and data visualization techniques.

Barioth
Messages
47
Reaction score
0
Hi!

Let's say in mathematica I declare this function

t[x_,y_]:= (x'+y')^2

Now I can call it with

$$L=1;$$
t[(#^2)+L &, (#^3)+L &]

if I call it this way it will remplace the # with s and evalute the derivative.

Now let's say I wana do this for for every L from 1 to 10.

so i got

Map[t[(#^2)+# &, (#^3)+# &],Range[1,10]]

and indeed this doesn't work. how can I tell mathematica that I want a # for my function t and one different # to use as my argument in my Map?

(*Note t I know that in this problem in make no sense to change the value of L since we're calculating the derivative. But I want to know for general purpose)
 
Physics news on Phys.org
I'm afraid I'm not terribly familiar with pure functions in MMA. However, I do have one question: could you do this in a For loop to get all your L values?
 
Ackbach said:
I'm afraid I'm not terribly familiar with pure functions in MMA. However, I do have one question: could you do this in a For loop to get all your L values?
A for loop would work, altough I want to use this in a Plot or a ListPlot. (I could do it with a For and save what's come out. But I would feel like its a ''Dirty'' solution.)

Thanks for passing by!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K