[Updated Code]
Hi everyone,
I was trying to use ImplicitEquations.jl
to graph some inequalities but I’m not using it properly I guess. Here is a minimal example that I am trying to plot
Code
using Plots, LaTeXStrings
using ImplicitEquations
I1 = (λ1, λ2) -> λ1^2 + λ2^2 + 1/(λ2^2 * λ1^2 )
I2 = (λ1, λ2) -> 0.5 * (I1(λ1, λ2)^2 - (λ1^4 + λ2^2 + 1/(λ2^4 * λ1^4 )))
cond1 = (λ1, λ2) -> I2(λ1, λ2)/I1(λ1, λ2) - 0.762 * I1(λ1, λ2) + 9.22 >= 0
cond2 = (λ1, λ2) -> I2(λ1, λ2)/I1(λ1, λ2)^2 + 0.0129 * I1(λ1, λ2) - 0.42 <= 0
cond3 = (λ1, λ2) -> I2(λ1, λ2)/I1(λ1, λ2) - 0.2515 * I1(λ1, λ2) + 0.1477 >= 0
l2l1 = (λ1, λ2) -> λ2 <= λ1
l1l2 = (λ1, λ2) -> λ2 >= λ1^(-0.5)
result = (cond1 ⩵ 0) & (cond2 ⩵ 0) & (l2l1 ⩵ 0) & (l1l2 ⩵ 0) | (cond3 ⩵ 0) # (((cond1 ≥ 0) & (cond2 ≤ 0)) | (cond3 ≥ 0)) & (l2l1 ≤ 0) & (l1l2 ≥ 0)
plot(result, xlims=(1, 6), ylims=(0, 6))
Error
ERROR: LoadError: MethodError: no method matching compute(::Array{Any,1}, ::ImplicitEquations.Region, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64)
Any hints on what could be going wrong?
Sympy equivalent (that I am trying to emulate in Julia)
from sympy import plot_implicit, Symbol, And, Or, Eq
def I1(l1, l2):
return l1**2. + l2**2. + 1./(l1**2. * l2**2.)
def I2(l1, l2):
return 1./2 * (I1(l1, l2)**2. - l1**4. - l2 ** 4. - 1./(l1**4. * l2**4.))
# defining the regions in the paper
def A(l1, l2):
I1v = I1(l1, l2)
I2v = I2(l1, l2)
cond1 = And(I2v/I1v - 0.762*I1v + 9.22 >= 0., I2v/I1v**2 + 0.0129*I1v - 0.42 <= 0.)
cond2 = I2v/I1v - 0.2515*I1v + 0.1477 >= 0.
cond3 = Or(cond1, cond2)
cond_l1_greater_l2 = And(l1 >= l2, cond3)
cond_l2_greater_l1_half = l2 >= l1**(-0.5)
return And(cond_l1_greater_l2, cond_l2_greater_l1_half)
lmbda1, lmbda2 = Symbol("lambda1", real=True), Symbol("lambda2", real=True)
plot_implicit(A(lmbda1, lmbda2), (lmbda1, 1., 6.), (lmbda2, 0.1, 6.), xlabel=r"$\lambda_1$", ylabel=r"$\lambda_2$", axis_center=(1.0, 0.0), size=(10, 8), backend="matplotlib")
which gives the expected result:
OS and Julia version
I am on Windows with Julia 1.5 and ImplicitEquations-1.0.3