TransWikia.com

Contour plot of greatest real root of an equation y^4=f(a,b)

Mathematica Asked by S Das on March 19, 2021

Can anyone tell me where I am going wrong? The output is blank. I am trying to contour plot the positive real value of (f(sigma, alpha1))^(1/4) in terms of variables sigma and alpha1.
Thanks in advance…

Λ1 = 100
β1 = 0.0000006
β2 = 0.00011
α2 = 359
μ1 = 0.0004
δ1 = .038
μ2 = 0.33
δ2 = 0.0227
k1 = 100000
r = 100
η1 = .6
μ3 = 0.142
R0[σ_, α1_] := 
 NSolve[y^4 - 
    Λ1 k1 β1 β2 α1 α2 
(1 - σ)/(3 μ1 μ2 μ3 δ2 (η1 + μ1 + 
δ1)) == 0, y, Reals]
ContourPlot[
 Max[y /. R0[σ_, α1_]], {σ, 
  0.01, .99}, {α1, 300, 350},
 ContourStyle -> None, Contours -> 100, PlotLegends -> Automatic, 
 LabelStyle -> {Black, 14}, 
 FrameLabel -> {"sigma", 
   "alpha 1"}, 
 ColorFunction -> "RedBlueTones"]

One Answer

Clear["Global`*"]

Λ1 = 100;
β1 = 0.0000006;
β2 = 0.00011;
α2 = 359;
μ1 = 0.0004;
δ1 = .038;
μ2 = 0.33;
δ2 = 0.0227;
k1 = 100000;
r = 100;
η1 = .6;
μ3 = 0.142;

A function that uses a numeric technique should have its arguments restricted to numeric values.

R0[σ_?NumericQ, α1_?NumericQ] := 
 NSolve[y^4 - Λ1 k1 β1 β2 α1 α2 (1 - 
σ)/(3 μ1 μ2 μ3 δ2 (η1 + μ1 + δ1)) ==
    0, y, Reals]

A Blank (pattern object) should not be used when calling a function.

ContourPlot[Max[y /. R0[σ, α1]],
 {σ, 0.01, .99}, {α1, 300, 350},
 PlotLegends -> Automatic,
 LabelStyle -> {Black, 14},
 FrameLabel -> {"σ", "α1"},
 ColorFunction -> "RedBlueTones"]

enter image description here

I reduced the number of contours so that the contours can be seen. Rather than using a high number of contours use DensityPlot.

DensityPlot[Max[y /. R0[σ, α1]],
 {σ, 0.01, .99}, {α1, 300, 350},
 PlotLegends -> Automatic,
 LabelStyle -> {Black, 14},
 FrameLabel -> {"σ", "α1"},
 ColorFunction -> "RedBlueTones"]

enter image description here

EDIT: If you want to both see contours and have a smooth color gradient use

Show[
 DensityPlot[Max[y /. R0[σ, α1]],
  {σ, 0.01, .99}, {α1, 300, 350},
  PlotLegends -> Automatic,
  LabelStyle -> {Black, 14},
  FrameLabel -> {"σ", "α1"},
  ColorFunction -> "RedBlueTones"],
 ContourPlot[Max[y /. R0[σ, α1]],
  {σ, 0.01, .99}, {α1, 300, 350},
  ContourShading -> None,
  PlotLegends -> Automatic,
  LabelStyle -> {Black, 14},
  FrameLabel -> {"σ", "α1"},
  ColorFunction -> "RedBlueTones"]]

enter image description here

Correct answer by Bob Hanlon on March 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP