Skip to main content

Resolving "The procedure entry point ... library vulkan-1.dll" error when launching Hyper Scape

Hi. As the title says, I resolved the following error. What I tried There were two. When you try these, you will need to take full responsibility for your action. Backup is important. The first one is a GPU driver update. Valkan will be installed along with the driver update, so I tried this method first. However, changing the driver sometimes causes instability, so I recommend checking the current version from the device manager. The second one is installing the latest version of Valkan Runtime. I referred to this nice Japanese article. https://emulog.net/ps3-emulator-rpcs3-cant-run-missing-vulkan-1-dll/ In my environment, the problem was resolved.  However, my GPU was too old to play :(  I hope these information helps you. Bye.

Easy programming at home - Part 4 Let’s draw the graph of “y = x²”

Hi, Good morning / afternoon / evening. I’m ponpokorin (@ponpokorin_24).

This is Part 4 of “Easy programming at home”. You can jump to Part 1 to 3 from the links below.

Part 1 What is programming in the first place
Part 2 Let's use R
Part 3 Let's use R 2

I'm going to use R this time too, so if you haven't seen Part 1, look it first.

Alright.

This time I'm going to write a program that can be used for studying math. Specifically, the goal is to "output a graph of function." You may think that it seems difficult... but if you get used to it, you'll be able to use easily.

The flow goes like this.

Table of Contents

  • Commands for drawing graphs
  • What you can customize when drawing a graph
  • Try to draw graph using “for” and “if” statements without plot command
  • Afterword

Let’s go!

Commands for drawing graphs

Let's search for a command that graphs the function.
I used the site called “R source” (http://cse.naro.affrc.go.jp/takezawa/r-tips/r.html) because my native language is Japanese. I recommend you should look for pages in your native language about R.

In R source, you can see “とりあえずplot()” at section “グラフィックス編”. I told you usage of plot based on this page.

It seems to draw a graph if you give a function as an argument. Let's try it with R Console first.

func1 <- function(x) x     # y = x
func2 <- function(x) x^2   # y = x^2
plot(func1)
plot(func2)

Could you draw a graph, right? I think you wonder at this statement function(x) x. This intuition is the correct. This is an abbreviated way of writing. If you write long,

func1 <- function(x){
    x
}

It is like this. In the second line, for clarity, I create a space on the left by using Tab key.
Also,

func1 <- function(x){
    x }

It is same meaning.

However, if you have only one process, it feels exaggerated. Therefore, this shortcut way is provided. If the processing inside {} can be done on one line, just omit the {} and write the command to the right of function(x), and it's OK.

Now, you know the commands to draw the graph, next, you can make the graph look a little better.

What you can customize when drawing a graph

First, let’s pick up something that can be customized roughly.

  • Color
  • Limit to display
  • Axis name etc.

Practice makes perfect, let’s write more and more! Let's use func2 from earlier.

plot(func2, col="red", xlim=c(-10, 10), ylim=c(-1, 10), xlab="x", ylab="x^2")


Compared to plot (func2), it is much longer and somewhat confusing, but the graph become a little easier to understand. Here is an explanation of the added commands.

col

Command to specify color. It can be specified as col="red" as above, or as number. For example, you can specify red even with col = 2.

xlim/ylim

This is the limit specification for each of the x-axis and y-axis. Let's specify so that it is easy to see. Note that after the =, it is written in the form c (lower limit, upper limit).

xlab/ylab

This is the specification of the label of each x-axis and y-axis. We put the character into "" after =.

To make the graph more understandable, you can do something like this.

plot(func2, col="red", xlim=c(-10, 10), ylim=c(-1, 10), xlab="x", ylab="x^2")
abline(v=0)
abline(h=0)


The axis of x = 0 and y = 0 can be drawn by abline. There is also other command like this.

plot(func2, col="red", xlim=c(-10, 10), ylim=c(-1, 10), xlab="x", ylab="x^2", tck=1)

This has a grid

That's all for customization. However, you can also customize the legend when drawing multiple graphs and the shape of the dot when creating a line graph. Check it out if you are interested.

Try to draw graph using “for” and “if” statements without plot command

To be honest, the initial goal of “output a graph of function” has been sufficiently achieved using only the commands introduced above, but I felt that the content was a little less as it was.

So, let's do this!

Simply speaking, a “for” statement is for iterative processing, and an “if” statement is for different processing depending on conditions. Let's try this first. I recommend that you write it in the editor first.

# for statement
x <- 0
for(i in 1:3){
    x<- x + i
}
x  # This x is 6

# if statement
x <- 2
if(x==2){
    x <- x+2
    print(x)
}else{
    x <- x-1
    print(x)
}

How about that? Did you know what kind of processing was done? I will explain!

“for” statement

I will explain the flow.

  1. At first, x is 0, but i is set to 1 first, and x <-x + i is executed. Then x is updated to 1.
  2. Next, i is replaced by 2, and x <-x + i is executed again. Then x is updated to 3.
  3. Finally i is replaced by 3 and once again x <-x + i is executed. x is updated to 6 and the for statement ends.
i in 1: 3 means that integers from 1 to 3 are assigned to i in order. Because of such processing, the for statement is sometimes called a for loop.


“if” statement

I will explain the flow too. I think “if” is easier to understand.

The inside of {} under if (x == 2) means that if x == 2, then do x <- x+2 and print (x). Inside the {} under else means that or else do x <- x-1 and print (x). To check the behavior of else, try changing x to 3, 4 or any number you like.

print is a command to display.

If you use the “for” statement, you can draw y = x² as a graph without plot. The following command is an example.

x <- seq(-100,100)
y <- c()

for(i in -100:100){
    y[i+101] <- i^2 
}

plot(x, y, col=2)

At this point the shape is well understood, but you can also draw this point as a smooth line.

plot(x, y, col=2, type="l") # It’s small L. Not large i

Perfect!

The commands used here are only the ones introduced so far. Take a break, and then remember how to use each command, so that you’ll be able to use them by yourself. Surely such experience should help you in the future.

Afterword

How was this Part? It may not have been very interesting, but it can be useful for math homework (of course to check the answer, right?). Also, the last sentence is surprisingly important. In many programming languages as well as R, various commands are created by combining basic commands with “for” and “if” statements.

When there is something else you want to do, if you don't have a suitable command or you can't find one, you may create original command using “for” and “if” statements (I'll do that in Part 5). So be sure to become familiar with the “for” and “if” statements along with the other basic commands!

If you find this article useful, please share on social media or school. Then the author will be glad!

Thank you for your reading! See you again!


Bonus section

Here is useful site for you who have read this far!

As We drew the graph above, a site called "wolframalpha" will do various mathematical calculations and drawings on a computer. It's a bit slow to load, but you can use it to check your own graphs or to check the solution of an equation. Look at it once.

Comments

Popular posts from this blog

Japanese education system and problems of university and employment system

Hi, Good morning / afternoon / evening. I’m ponpokorin ( @ponpokorin_24 ). In this article, I will briefly explain the Japanese education system, then explain the internals of Japanese universities and the connection between universities and occupations. I am currently attending a university in Japan, so I can write more realistically. I would like to know about the state around Japanese universities. Table of contents Japanese education system Current state of Japanese universities Japanese employment system Afterword Japanese education system First, I would like to see the flow from kindergarten to university and 専門学校. Until children enter elementary school, each family can take a different choice, but after entering elementary school, children will generally go to elementary school, junior high school, and high school in six, three, and three years. Please see the image below for a rough overview. Reference: Ministry of education, culture, sport, science, and tec

Resolving "The procedure entry point ... library vulkan-1.dll" error when launching Hyper Scape

Hi. As the title says, I resolved the following error. What I tried There were two. When you try these, you will need to take full responsibility for your action. Backup is important. The first one is a GPU driver update. Valkan will be installed along with the driver update, so I tried this method first. However, changing the driver sometimes causes instability, so I recommend checking the current version from the device manager. The second one is installing the latest version of Valkan Runtime. I referred to this nice Japanese article. https://emulog.net/ps3-emulator-rpcs3-cant-run-missing-vulkan-1-dll/ In my environment, the problem was resolved.  However, my GPU was too old to play :(  I hope these information helps you. Bye.

Molting and Secondary growth of Apple tree

Hi. There are various discoveries when you grow plants by yourself. Today I took a picture of the molting (maybe there is a formal name...) of the new shoot of an apple tree in the second year of seedlings. The above picture is hard to look the "molting", so I expanded. If you look closely, you'll find a skin that is transparent and can be peeled off easily. When I first raised an apple tree, I thought it was an illness, but it is growing without dying. So now, I'm thinking it's one of the physiological phenomena. By the way, "Secondary growth" is another phenomenon. The trunk becomes thicker with vertical cracks as shown in the image below. At the beginning, I was worried about various things. For example, I thought my apple tree got sick by seeing the white hair (trichome) of the buds (I didn't know the buds has it). But after a year, I get used to raising apple trees. In how many years will apple trees grown from seeds bear fruit? I can't wait