0
|
6331 Views
|
14 Replies
|
3 Total Likes
View groups...
Share

# Plot all possible values of a function on a range

Posted 4 years ago
 Let say I have a function f[x_,y_,z_]:=x^3+Abs[(E^y)-5z] x=Range[0,2.65] y=Range[0,3.86] z=Range[0,6]  Now I have to plot all possible values of the function f[x,y,z] against z. It will look like to scattered discrete points in f-z plane.
14 Replies
Sort By:
Posted 4 years ago
 Hi John,Is this what you are looking for? data = Table[{f[x, y, z], z}, {x, 0, 2.65, .1}, {y, 0, 3.86, .1}, {z, 0, 6, .1}] // Flatten[#, 2] &; ListPlot[data, PlotRange -> All, FrameLabel -> (Style[#, 14, Bold] & /@ {"f", "z"}), Frame -> True] 
Posted 4 years ago
 Thanks.
Posted 4 years ago
 When applied the same approach for a complicated function which has 14 variables the program seems extremely slow taking several hours. Is there any alternative approach for this kind of problem?
Posted 4 years ago
 Hi John,It really depends on the granularity you need for each of the 14 variables, and on the time it takes for the complex function to execute. If the complex function can be compiled, you can try that. Reducing granularity will also speed up the generation of the table. You could also experiment with ParallelTable if you have access to multiple kernels.
Posted 4 years ago
 I think the problem using 14 variables is with granularity which you have mentioned ( even reducing the granularity significantly it is creating 10^6 orders of datas which are taking too much time to plot) . But is this possible to create a random data set of those 14 variables with less no of points, like (a, b, c, ....) each having random values with range specified and I want to generate only 200 of those dataset and then plot them.
Posted 4 years ago
 You can (quickly) get a 200x14 array of RandomReal in the range 0. to 6., like this: RandomReal[{0, 6}, {200, 14}]; 
Posted 4 years ago
 Hi John,Here is one way to generate random values with specific ranges for each variable. Using the ranges from your original question: points := {RandomReal[{0, 2.65}], RandomReal[{0, 3.86}], RandomReal[{0, 6}]}; Table[points, 200] 
Posted 4 years ago
 Thanks for your answer. Can you show me how this random number can be put in a code relating the function variables and how to get a plot as like your first answer.
Posted 4 years ago
 Here is one way ClearAll[f, points] f[x_, y_, z_] := x^3 + Abs[(E^y) - 5 z] points := {RandomReal[{0, 2.65}], RandomReal[{0, 3.86}], RandomReal[{0, 6}]} data = Table[{f @@ points, Last@points}, 200]; ListPlot[data] 
Posted 4 years ago
 May be something like this one: f[x_, y_, z_] := x^3 + Abs[(E^y) - 5 z] Plot3D[Table[f[x, y, z], {z, 0, 6, 0.5}], {x, 0, 2.65}, {y, 0, 3.86}] 
Posted 4 years ago
 Thanks a lot. But I have a simple doubt how the code will understand z will take the Last points , i.e. how to tell the code which RandomReal[] block specify which variable. It is required when I have to plot f vs x rather than f vs z.
Posted 4 years ago
 The values returned by points, list of {x, y, z}, are passed to f in the same order. Simple example SeedRandom[123]; point = points (* {1.20766, 3.77441, 5.65929} *) f@@point (* 17.0366 *) Is the same as f[point[[1]], point[[2]], point[[3]]] (* 17.0366 *) To plot f[x, y, z] vs x, generate the table as {f @@ points, First@points} To plot against y {f @@ points, points[[2]]} 
Posted 4 years ago
 Thanks, Rohit,But the ordinary parameter scan and random parameter scan plot differs significantly. Is this possible to get an overall similar plot using random scan also than it will be easy to get the data interpretation with lesser no of points.
Posted 4 years ago
 Hi, RohitCan you help me to do the same thing using Subdivision array by generating some points corresponding to each variables and generate the function values at each set