omkardpd

50 Reputation

2 Badges

8 years, 114 days

MaplePrimes Activity


These are questions asked by omkardpd

Hi,

I am trying to generate a plot using a procedure. A dummy code is as follows:

***

fun := piecewise(x+y > 1, (x+y)^2, x-y);

temp_proc := proc(x, y)
local out, ind:

ind := 9:

if x > y then ind := 1 else ind := 0 end if; 

if ind = 1 then out := eval(5*fun, {:-x=x, :-y=y}) else out := eval(-5*fun, {:-x=x, :-y=y}) end if:

return(out);
end proc:

xt := 5: yt := 2:
out1_fin := temp_proc(xt, yt);

plot(out1_fin, z=-2..3);
 

***

The issue is as follows:

1. I am getting an error message for the code above: "Error, (in temp_proc) cannot determine if this expression is true or false: 2 < z".

2. The entire procedure and the plot command work well for a fixed "z". However, it is not useful for me as I am looking for a plot for various values of z. 

3. I hope I don't have to run the procedure by manually creating a list of z and then plotting the lists of z and out1_fin. 

4. I am using the "ind" variable because it simplifies my actual code, which involves multiple conditions defining the function "fun" that I need to plot. 

I would appreciate your input on how to resolve the issue. 

Regards,

Omkar

 

Hi, 
I am struggling with the output of a procedure. A dummy code is as follows:

*****

fun := x^2+y^2;

temp_proc := proc(x, y)
local out1, out2, out3:

if x > 0 then out1 := fun; out2 := 2*fun; out3 := k*fun;
elif x <= 0 then out1 := fun; out2 := -2*fun; out3 := -k*fun;
end if:

return(out1, out2, out3);
end proc:

xt := -1: yt := 2:
out1_fin := temp_proc(xt, yt)[1];
out2_fin := temp_proc(xt, yt)[2];
out3_fin := temp_proc(xt, yt)[3];


*****

xt and yt are numerical input parameters. I expect to obtain "out1_fin" and "out2_fin" in numerical form and "out3_fin" in symbolic form. All three outputs should substitute xt and yt for x and y, respectively, wherever relevant. 

However, currently, the output I am getting is not after substituting the values of xy and yt. The output is as follows:

*****

out1_fin := x^2+y^2

out2_fin := -2*x^2-2*y^2          

out3_fin := -k*(x^2+y^2)

*****

May I get some help in resolving the issue? 

Also, would a procedure be a good idea for this task, or would a module be better? 

I would appreciate any guidance in this regard. Thank you. 

Regards,

Omkar

Hi,

I am using the following (dummy) code to generate a density plot.

densityplot(x-y^2, x=-5..5, y=-5..5, axes=boxed, style=patchnogrid, numpoints=1000, legendstyle=[location=bottom], labels=[x, y]);

While this command does generate x vs y plots with varying color shared, I cannot figure out where the function (x-y^2) value by looking at the color shades. Is there a way to produce a legend along with the plot that will demonstrate how the function is taking different values with parameters? 

I found a similar post, dated 2005, that suggests using the "s_tyle=" command. However, it does not work for some reasons. I would appreciate help in this regard. 

Thank you,

Omkar

Hi,

I am struggling with an issue of the solutions produced by the "fsolve" command for a polynomial with multiple solutions. I am running the commands that are represented as follows:

f := x^2-x+0.25:

fsolve({f=0}, x=0..1);

It produces multiple solutions as follows:

{x = 0.5000000000}, {x = 0.5000000000}

What I am looking for is as follows:

1. Store multiple solutions separately.

2. For each solution, separate the variable "x=" and the numerical value "0.50000000". 

I would appreciate inputs from the team. 

Thank you,

Omkar

 

 


Dear Colleagues,

Apologies for the generic question below.

I am trying to obtain the Nash equilibrium solutions for a two-person game. I am not sure of any in-built packages that can help me in obtaining the solutions computationally. The algorithms that I created do not seem to give good solutions that are meaningful in my application. Any suggestion would be much appreciated. 

Regards,

Omkar

 

 

1 2 3 Page 1 of 3