Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8810699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:10:55+00:00 2026-06-14T03:10:55+00:00

For example, I have such set of complex points: and I want to plot

  • 0

For example, I have such set of complex points:

preimage

and I want to plot an image of function (for example, f(z) = -cos(z)) from the preimage:

image

Here is my code for this:

from numpy import *
import matplotlib.pyplot as plt

z_0 = []
N = 500
u = linspace(0.0, pi, N)
v = linspace(0.0, 15.0, N)
for i in xrange(N):
    for j in xrange(N):
        z_0.append(u[i] + 1j * v[j])
z = -cos(z_0)
plt.plot(real(z), imag(z), linestyle='', marker='x')
plt.grid(True)
plt.show()

Can I get rid of two nested loops? Is there any better way to solve the problem using numpy/matplotlib standard functions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:10:57+00:00Added an answer on June 14, 2026 at 3:10 am

    You could use numpy.meshgrid:

    >>> from numpy import linspace, meshgrid, pi
    >>> u = linspace(0, pi, 3)
    >>> v = linspace(0, 10, 3)
    >>> uu, vv = meshgrid(u, v)
    >>> uu
    array([[ 0.        ,  1.57079633,  3.14159265],
           [ 0.        ,  1.57079633,  3.14159265],
           [ 0.        ,  1.57079633,  3.14159265]])
    >>> vv
    array([[  0.,   0.,   0.],
           [  5.,   5.,   5.],
           [ 10.,  10.,  10.]])
    >>> z = uu + 1j * vv
    >>> z
    array([[ 0.00000000 +0.j,  1.57079633 +0.j,  3.14159265 +0.j],
           [ 0.00000000 +5.j,  1.57079633 +5.j,  3.14159265 +5.j],
           [ 0.00000000+10.j,  1.57079633+10.j,  3.14159265+10.j]])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have some openGL code (such code for example) /* FUNCTION: YCamera ::
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
If you have a url such as the one as follows: http://www.example.com/400x200 is it
If I have, for example, a list of tuples such as a = [(1,2)]
I have 3 tables in my database, for example with such names: TableA, TableB,
Example: I have an class that inherits from UIImageView. An object creates an instance
Take this simple, contrived example: UserRepository.GetAllUsers(); UserRepository.GetUserById(); Inevitably, I will have more complex queries,
I have one question, I have such code this._engine = Python.CreateEngine(); ScriptSource source =
In My application i want to flip the view.. I have seen such animation
Problem I have such code var ls = src.iter.toList src.iter = ls.iterator (this is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.