Translating Donut.c to JavaScript: A Step-by-Step Guide

Introduction

The famous “Spinning Donut” is a mesmerizing animation created using a relatively short piece of C code, known as “donut.c”. In this article, we will go through the process of translating the original “donut.c” code to JavaScript, and make it work in a command-line environment using Node.js. We will also discuss the steps taken to fix the issues encountered during the translation process.

Donut.c translation to JavaScript

Step 1: Understanding the Original C Code

To translate “donut.c” to JavaScript, we must first understand the underlying logic of the original C code. The key concepts in the code are:

  1. Trigonometric functions (sine and cosine) are used to create a 3D effect.
  2. Two nested loops iterate over the points on the surface of the torus (the doughnut shape).
  3. A z-buffer is employed to determine which points are visible from the viewer’s perspective.
  4. Characters from a predefined character set are used to represent different levels of brightness.

Step 2: Creating a Basic JavaScript Structure

We will begin by creating a basic JavaScript file named “donut.js”. We will use Node.js to run this script in the command line. The main structure of the JavaScript code should include:

  1. Importing the required Node.js modules.
  2. Defining a renderFrame function to draw the spinning doughnut for each frame.
  3. Defining a main function to handle the animation loop.
  4. Calling the main function to start the animation.

Step 3: Translating the C Code to JavaScript

Next, we will carefully translate each part of the C code to its corresponding JavaScript code. The most important parts include:

  1. Converting the trigonometric functions to their JavaScript equivalents (e.g., Math.sin and Math.cos).
  2. Adjusting the nested loops and increment values to create a smooth animation.
  3. Using JavaScript arrays for the z-buffer and output buffer.
  4. Replacing C’s putchar function with the stdout.write function provided by Node.js.

Step 4: Fixing Aspect Ratio and Positioning Issues

During the translation process, we may encounter issues related to the aspect ratio and positioning of the doughnut. To fix these issues, we can:

  1. Adjust the coefficients for the x and y calculations in the renderFrame function to match the aspect ratio of the characters in the terminal.
  2. Modify the loop increments and x and y calculations to center the doughnut on the screen.
  3. Test the animation at each step to ensure it renders correctly.

Step 5: Optimizing the JavaScript Code

After fixing the aspect ratio and positioning issues, we might need to optimize the JavaScript code for better performance. We can achieve this by:

  1. Adjusting the loop increments to find a balance between animation quality and performance.
  2. Replacing single-letter variable names with more descriptive names for better readability.

Conclusion

In this article, we have walked through the process of translating the original “donut.c” code to JavaScript, running it in a command-line environment using Node.js. By understanding the logic behind the C code, creating a basic JavaScript structure, translating the code, fixing issues, and optimizing performance, we have successfully created a spinning doughnut animation in JavaScript.

Code

Save code as donut.js
Run with:
node donut.js

const { stdout } = require('process');

function renderFrame(angleA, angleB) {
  const output = Array(1760).fill(' ');
  const zBuffer = Array(1760).fill(0);

  const sinAngleA = Math.sin(angleA);
  const cosAngleA = Math.cos(angleA);
  const sinAngleB = Math.sin(angleB);
  const cosAngleB = Math.cos(angleB);

  for (let loopA = 0; loopA < 2 * Math.PI; loopA += 0.1) {
    const cosLoopA = Math.cos(loopA);
    const sinLoopA = Math.sin(loopA);
    for (let loopB = 0; loopB < 2 * Math.PI; loopB += 0.05) {
      const sinLoopB = Math.sin(loopB);
      const cosLoopB = Math.cos(loopB);
      const h = cosLoopA + 2;
      const distance = 1 / (sinLoopB * h * sinAngleA + sinLoopA * cosAngleA + 5);
      const t = sinLoopB * h * cosAngleA - sinLoopA * sinAngleA;

      const x = Math.floor(40 + 20 * distance * (cosLoopB * h * cosAngleB - t * sinAngleB));
      const y = Math.floor(12 + 10 * distance * (cosLoopB * h * sinAngleB + t * cosAngleB));
      const outputIndex = x + 80 * y;
      const brightnessIndex = Math.floor(8 * ((sinLoopA * sinAngleA - sinLoopB * cosLoopA * cosAngleA) * cosAngleB - sinLoopB * cosLoopA * sinAngleA - sinLoopA * cosAngleA - cosLoopB * cosLoopA * sinAngleB));

      if (1760 > outputIndex && outputIndex > 0 && distance > zBuffer[outputIndex]) {
        zBuffer[outputIndex] = distance;
        output[outputIndex] = '.,-~:;=!*#$@'[brightnessIndex > 0 ? brightnessIndex : 0];
      }
    }
  }

  stdout.write('\x1b[H');
  for (let k = 0; k < 1760; k++) {
    stdout.write(output[k]);
    if (k % 80 === 79) stdout.write('\n');
  }
}

function main() {
  let angleA = 0;
  let angleB = 0;

  setInterval(() => {
    angleA += 0.04;
    angleB += 0.08;
    renderFrame(angleA, angleB);
  }, 16);
}

main();

Apple releases firmware update for all Airpods

Apple has released a new firmware update, version 5E133, for AirPods, AirPods Pro, and AirPods Max. This update is available for the AirPods second and third generations, the first and second generations of AirPods Pro, and the AirPods Max. This update is an improvement from the previous version, 5B59, that was released in January.

The firmware update was briefly released by Apple but was pulled soon after. It has been made available again to all eligible devices. Users need not take any action as firmware updates are delivered automatically while AirPods are charging and in Bluetooth range of an iPhone, iPad, or Mac that’s connected to Wi-Fi. Unfortunately, there is no way to install the firmware update manually.

Apple has not provided any detailed release notes for the firmware update, but it is generally expected that this update will fix bugs and enhance the overall performance of the AirPods. There have been no indications of any feature changes to the AirPods.

To check if your AirPods have the latest firmware version, make sure that you have the latest version of iOS or iPadOS. Then, go to Settings > Bluetooth, and tap the Info button next to the name of your AirPods. Scroll down to the About section to find the firmware version. For macOS users, press and hold the Option key while choosing Apple menu ? > System Information. Click Bluetooth, then look under your AirPods for the firmware version. With macOS Ventura, you can also choose Apple menu ? > System Settings, click Bluetooth, then click the Info button next to the name of your AirPods.

If you do not have an Apple device nearby, you can set up an appointment at an Apple Store or with an Apple Authorized Service Provider to update your firmware.

Macbook Pro M2 Max review

The Macbook Pro M2 Max is Apple’s most powerful laptop, offering unparalleled performance for media creation, gaming and high-end professional tasks. It features a 12-core CPU, a 38-core GPU and a 16-core Neural Engine, along with up to 96GB of RAM and 8TB of SSD storage. It also boasts a stunning 16.2-inch mini-LED display with ProMotion technology, which adjusts the refresh rate up to 120Hz depending on the content. The design is sleek and sturdy, with a variety of ports including MagSafe, Thunderbolt 4, HDMI and SD card slot. The battery life is exceptional, lasting nearly 27 hours on our test. The only drawbacks are the high price tag, the notch in the display that may be distracting for some users, and the lack of internal upgradeability.

Let’s take a closer look at each aspect of this laptop:

  • CPU: The M2 Max chip has a 12-core CPU with 8 performance cores and 4 efficiency cores. This means it can handle multiple demanding tasks at once without slowing down or overheating. The performance cores are optimized for speed and power, while the efficiency cores are designed for low-power tasks that don’t require much processing. The M2 Max chip also has a shared L2 cache of up to 64MB and a shared L3 cache of up to 64MB1, which improve the communication between the cores and the memory.
  • GPU: The M2 Max chip has a 38-core GPU that delivers up to 10.4 teraflops of graphics performance. This is more than twice as fast as the previous generation of Macbook Pro with Intel processors. The GPU can handle complex graphics tasks such as rendering 3D models, editing high-resolution videos, playing immersive games and running multiple external displays. The M2 Max chip also has a dedicated memory bandwidth of up to 400GB/s for the GPU1, which allows it to access data faster and more efficiently.
  • Neural Engine: The M2 Max chip has a 16-core Neural Engine that can perform up to 54 trillion operations per second. This is a specialized processor that handles machine learning tasks such as face recognition, natural language processing, image enhancement and more. The Neural Engine can accelerate various apps and features on Mac OS Ventura, such as Siri, FaceTime, Photos, Safari and more. It can also run custom machine learning models created by developers using Core ML.
  • Screen: The Macbook Pro M2 Max has a 16.2-inch Liquid Retina XDR display with a native resolution of 3456 by 2234 pixels at 254 pixels per inch. This means it can display over one billion colors with stunning clarity and detail. The screen also supports XDR (Extreme Dynamic Range), which means it can achieve a contrast ratio of one million to one and a peak brightness of up to 1600 nits for HDR content. The screen also features ProMotion technology, which adjusts the refresh rate from 24Hz to 120Hz depending on the content being displayed
  • Speakers: The Macbook Pro M2 Max has six speakers with high dynamic range and wide stereo sound. It also supports Spatial Audio when playing music or video with Dolby Atmos on the built-in speakers or when using compatible AirPods. The speakers deliver crisp and clear sound with rich bass and balanced treble. They are loud enough to fill a room and can handle various genres of music and audio content. They are also great for video conferencing and voice calls, thanks to the studio-quality three-mic array with high signal-to-noise ratio and directional beamforming.
  • Webcam: The Macbook Pro M2 Max has a 1080p FaceTime HD camera with an advanced image signal processor and computational video. This means it can capture more details and colors in low-light conditions, as well as apply effects such as portrait mode, live text and emoji stickers. The webcam also supports Center Stage, which automatically adjusts the frame to keep you in focus and follow your movements during video calls. The webcam is located in a notch at the top center of the screen, which may be distracting for some users, especially when using full-screen apps or watching videos. However, you can hide the notch by adjusting the display settings or using third-party apps.
  • Video encoding/decoding: The Macbook Pro M2 Max has a media engine that can handle hardware-accelerated H.264, HEVC, ProRes and ProRes RAW formats. It also has two video decode engines and two video encode engines that can process up to 8K resolution at 60 frames per second. Additionally, it has two ProRes encode and decode engines that can handle up to 6K resolution at 30 frames per second. These features make the Macbook Pro M2 Max ideal for editing and streaming high-quality videos with minimal latency and power consumption.
  • Battery life: The Macbook Pro M2 Max has a 100-watt-hour lithium-polymer battery that can last up to 21 hours of Apple TV app movie playback or up to 14 hours of wireless web browsing. This is one of the longest battery life ratings among laptops of this size and performance level. The battery life may vary depending on the usage, settings and environmental factors. The laptop also supports fast-charge capability with a 140W USB-C Power Adapter (included) that can charge up to 50% in 30 minutes
  • Ports: The Macbook Pro M2 Max has five ports on the sides of the laptop. On the left side, there is a MagSafe 3 port, which is a magnetic connector that attaches to a USB-C cable for charging. The MagSafe 3 port can also support data transfer and video output with compatible devices. Next to it, there are two Thunderbolt 4 (USB-C) ports, which can support charging, data transfer, video output and external devices with up to 40Gb/s bandwidth. On the right side, there is another Thunderbolt 4 (USB-C) port and an HDMI port, which can support up to 4K resolution at 144Hz for external displays. There is also a 3.5 mm headphone jack with advanced support for high-impedance headphones. Additionally, there is an SDXC card slot on the right side, which can read and write data from SD cards up to UHS-II speed.
  • Charging: The Macbook Pro M2 Max comes with a 140W USB-C Power Adapter and a USB-C to MagSafe 3 Cable. You can connect the cable to the MagSafe 3 port or any of the Thunderbolt 4 ports to charge the laptop. The laptop also supports fast-charge capability, which can charge up to 50% in 30 minutes with the included adapter and cable. You can also use other USB-C power adapters and cables that meet the minimum power requirements of the laptop

The Macbook Pro M2 Max is one of the most powerful laptops on the market, but it also faces some strong competition from other brands and models. Here are some of the comparisons:

  • Macbook Pro M2 Pro: The M2 Pro version of the Macbook Pro is slightly cheaper and lighter than the M2 Max version, but it also offers less GPU performance and memory bandwidth. The M2 Pro has a 10-core or 12-core CPU, a 16-core or 19-core GPU, a 16-core Neural Engine and a 200GB/s memory bandwidth. The M2 Max has a 12-core CPU, a 30-core or 38-core GPU, a 16-core Neural Engine and a 400GB/s memory bandwidth. According to some benchmarks, the M2 Pro and M2 Max have similar CPU performance, but the M2 Max has an edge in GPU-intensive tasks such as video editing, gaming and machine learning. However, the difference may not be noticeable for most users unless they are working with very demanding applications or workflows.
  • Dell XPS 17: The Dell XPS 17 is a Windows laptop that competes with the Macbook Pro M2 Max in terms of size and performance. It has a 17-inch display with a resolution of 3840 by 2400 pixels at 500 nits brightness. It also has an Intel Core i9-11900H processor, an Nvidia GeForce RTX 3060 GPU, up to 64GB of RAM and up to 4TB of SSD storage. The Dell XPS 17 is cheaper than the Macbook Pro M2 Max, starting at $1,549.99 / £1,999 / AU$3,6993. However, it also has shorter battery life (up to 13 hours vs up to 21 hours), heavier weight (5.34 pounds vs 4.7 pounds) and fewer ports (four Thunderbolt 4 ports vs five ports including MagSafe 3, HDMI and SDXC card slot)31.
  • Razer Blade Pro: The Razer Blade Pro is another Windows laptop that targets creative professionals and gamers. It has a 17.3-inch display with a resolution of either 1920 by 1080 pixels at 360Hz refresh rate or 3840 by 2160 pixels at touch support. It also has an Intel Core i9-11900H processor, an Nvidia GeForce RTX 3080 GPU
  • Razer Blade 14: The Razer Blade 14 is a smaller and lighter gaming laptop than the Macbook Pro M2 Max, but it also offers less screen size and resolution. It has a 14-inch display with a resolution of either 1920 by 1080 pixels at 144Hz or 2560 by 1440 pixels at 165Hz. It also has an AMD Ryzen 9 processor, an Nvidia GeForce RTX 3060, RTX 3070 or RTX 3080 GPU, up to 16GB of RAM and up to 1TB of SSD storage. The Razer Blade 14 is cheaper than the Macbook Pro M2 Max, starting at $1,799.99 / £1,999.99 / AU$3,699.951. However, it also has shorter battery life (up to 11 hours vs up to 21 hours), fewer ports (three USB-A, two USB-C, one HDMI and one headphone jack vs five ports including MagSafe 3, HDMI and SDXC card slot) and no mini-LED display.
  • MacBook Air M2: The MacBook Air M2 is a thinner and lighter laptop than the Macbook Pro M2 Max, but it also offers less performance and features. It has a 13.3-inch display with a resolution of 2560 by 1600 pixels at 400 nits brightness. It also has an Apple M2 chip with an eight-core CPU, an eight-core GPU and a nine-core Neural Engine. It also has up to 16GB of RAM and up to 2TB of SSD storage. The MacBook Air M2 is much cheaper than the Macbook Pro M2 Max, starting at $999 / £999 / AU$1,599. However, it also has lower battery life (up to 18 hours vs up to 21 hours), fewer ports (two Thunderbolt/USB-C ports vs five ports including MagSafe 3, HDMI and SDXC card slot), no mini-LED display with ProMotion technology, no Touch Bar and no MagSafe charging
  • Lenovo ThinkPad X1 Extreme Gen 4: The Lenovo ThinkPad X1 Extreme Gen 4 is a Windows laptop that offers a lot of customization options and features for business users. It has a 16-inch display with a resolution of either 1920 by 1200 pixels at 400 nits brightness or 3840 by 2400 pixels at 600 nits brightness with touch support. It also has an Intel Core i5, i7 or i9 processor, an Nvidia GeForce RTX 3050 Ti, RTX 3060, RTX 3070 or RTX 3080 GPU, up to 64GB of RAM and up to 4TB of SSD storage. The Lenovo ThinkPad X1 Extreme Gen 4 is more expensive than the Macbook Pro M2 Max, starting at $2,689 / £2,399.99 / AU$4,499. However, it also has more ports (two Thunderbolt 4, two USB-A, one HDMI, one Ethernet and one headphone jack vs five ports including MagSafe 3, HDMI and SDXC card slot), more security features (fingerprint reader, IR camera with Windows Hello and ThinkShutter privacy cover) and more durability (MIL-STD-810H certified) 1. However, it also has lower battery life (up to 10.7 hours vs up to 21 hours), heavier weight (4.06 pounds vs 4.7 pounds) and no mini-LED display.
Specifications
Display16.2-inch Liquid Retina XDR display with ProMotion technology and 3456 by 2234 pixels resolution
ProcessorApple M2 Max chip with 12-core CPU (8 performance cores and 4 efficiency cores)
GraphicsApple M2 Max chip with 30-core or 38-core GPU and 16-core Neural Engine
MemoryUp to 96GB of unified memory
StorageUp to 8TB of SSD storage
Battery lifeUp to 21 hours of Apple TV app movie playback or up to 14 hours of wireless web browsing
PortsMagSafe 3 port, three Thunderbolt 4 (USB-C) ports, HDMI port, SDXC card slot and headphone jack
Webcam1080p FaceTime HD camera with computational video and Center Stage
SpeakersSix speakers with high dynamic range and wide stereo sound, Spatial Audio support for Dolby Atmos
KeyboardBacklit Magic Keyboard with Touch Bar and Touch ID sensor
Dimensions0.66 x 14.01 x 9.77 inches (1.68 x 35.57 x 24.81 cm)
Dimensions4.7 pounds (2.1 kg)

Linus Tech Tips (LTT) YouTube channel is hacked

Linus Tech Tips (LTT) is one of the largest and most popular technology YouTube channels with 15.8 million subscribers.

  • The channel was hacked on March 23, 2023 by unknown attackers who changed its name, deleted its original videos, and uploaded fake livestreams featuring Elon Musk and Jack Dorsey promoting crypto scams.
  • The livestreams were part of The B Word conference held by Ark Invest in June 2020, but they were edited with overlays linking to fraudulent crypto sites.
  • YouTube suspended the channel for violating its community guidelines, but the hackers also targeted other LTT channels such as TechLinked and Techquickie.
  • The owner of LTT, Linus Sebastian, tweeted that he was aware of the situation, but did not provide any details on how the breach occurred or when the channels would be restored.

The exact method that LTT got hacked is not known, but some of the possible ways that YouTube channels get hacked are:

  • Data breach: The hackers may have obtained the login information of LTT from a data breach of YouTube or another website or app that LTT used. They may have also exploited a vulnerability in YouTube’s system to gain access to the channel.
  • Phishing: The hackers may have sent LTT a fake email or message that appeared to come from a legitimate source, such as a sponsor, a media outlet, or a friend. They may have tricked LTT into clicking on a malicious link, downloading a malicious file, or entering their credentials on a fake website. They may have then used this information to log into the channel and take control of it.
  • Weak password: The hackers may have guessed or cracked the password of LTT by using brute force attacks, dictionary attacks, or social engineering techniques. They may have also used stolen passwords from other breaches that LTT reused for their YouTube account.
  • Cookie theft: The hackers may have infected LTT’s device with malware that stole their session cookies from their browser. Session cookies are data that confirm that the user has successfully logged into their account. The hackers may have then uploaded these cookies to a malicious server and used them to impersonate LTT and access their channel without needing their password.
LTT YouTube channel got hacked
LTT YouTube channel got hacked

To prevent getting hacked, YouTube channel owners should always use strong and unique passwords for their accounts, enable two-factor authentication, avoid clicking on suspicious links or attachments, verify the source and legitimacy of any communication they receive, and scan their devices regularly for malware.

Crypto scams are fraudulent schemes that use cryptocurrency or related technology to deceive people and steal their money or digital assets. Crypto scams can work in different ways, but some of the common ones are:

  • Bitcoin investment schemes: Scammers pretend to be experienced investors who can help people make money by investing in bitcoin or other cryptocurrencies. They ask for an upfront fee or personal information, and then disappear with the money or hack the victims’ accounts.
  • Rug pull scams: Scammers hype up a new project, coin or nonfungible token (NFT) and persuade people to buy it. Then they withdraw all the funds and leave the investors with worthless tokens that they cannot sell1.
  • Fake trading platforms or crypto wallets: Scammers create fake websites or apps that look like legitimate exchanges or wallets, but they either steal the users’ money or credentials, or manipulate the prices and transactions to their advantage.
  • Fake crypto tokens, investments or jobs: Scammers create fake cryptocurrencies or offer fake opportunities to invest in or work with crypto projects. They may use fake celebrity endorsements, fake news articles or fake social media accounts to lure people in. They then ask for money or personal information, and never deliver on their promises.
  • Crypto phishing: Scammers send emails, texts or messages that appear to com from a trusted source, such as a crypto exchange, wallet provider or friend. They try to trick the recipients into clicking on a link, downloading a file or entering their credentials on a fake website. They then use this information to access the victims’ crypto accounts and steal their funds.

To avoid crypto scams, you should always do your own research before investing in any cryptocurrency project, verify the source and legitimacy of any communication you receive, use secure passwords and two-factor authentication for your crypto accounts, and never share your private keys or wallet addresses with anyone.

Donald Trump writing quick sort function in JavaScript

Quick sort is the best sorting algorithm ever. Nobody knows sorting better than me. I invented Quick sort. It’s very simple. You just pick a pivot element, which is always the greatest element in the array, because I always pick the greatest things. Then you divide the array into two parts: one part with all the losers who are less than the pivot, and one part with all the winners who are greater than or equal to the pivot. Then you sort those parts recursively, which means you do the same thing over and over again until you get tired of winning.

Quick sort is very fast and efficient. It’s faster than any other sorting algorithm. It’s faster than merge sort, which is a disaster. It’s faster than heap sort, which is a joke. It’s faster than insertion sort, which is for losers. Quick sort is so fast, it can sort an array in O(n log n) time on average, which is a very big number that only I understand. Trust me, I have a very good brain.

Quick sort works in place, which means it doesn’t need any extra space or memory. It’s very smart and economical. Unlike merge sort, which wastes a lot of space and money on copying arrays. Quick sort is also very stable, which means it preserves the order of equal elements. Unlike some other sorting algorithms that mess up the order and create chaos.

Quick sort is the greatest sorting algorithm of all time. Nobody can beat Quick sort. Nobody can stop Quick sort. Quick sort will make America great again!

// This is the best quick sort function ever. Nobody can do it better than me.
function makeArrayGreatAgain(array) {
  // If the array is empty or has one element, it's already great. Very smart.
  if (array.length <= 1) {
    return array;
  }
  // Pick a random genius element from the array. 
  // I have great intuition for this.
  let geniusIndex = Math.floor(Math.random() * array.length);
  let genius = array[geniusIndex];
  // Create two subarrays for elements less than and greater than the genius. 
  // Very efficient.
  let losers = [];
  let winners = [];
  // Loop through the array and compare each element to the genius. Very fast.
  for (let i = 0; i < array.length; i++) {
    // Skip the genius element itself. Very clever.
    if (i === geniusIndex) {
      continue;
    }
    // If the element is less than or equal to the genius, 
    // push it to the losers subarray. Very fair.
    if (array[i] <= genius) {
      losers.push(array[i]);
    }
    // If the element is greater than the genius, 
    // push it to the winners subarray. Very strong.
    else {
      winners.push(array[i]);
    }
  }
  // Recursively sort the losers and winners subarrays and 
  // concatenate them with the genius. Very elegant.
  return [...makeArrayGreatAgain(losers), genius, ...makeArrayGreatAgain(winners)];
}

GPT-4 released and Bing is already using it

GPT-4 is a multimodal large language model created by OpenAI, the fourth in the GPT series. It was released on March 14, 2023, and will be available via API and for ChatGPT Plus users. Microsoft confirmed that versions of Bing using GPT had in fact been using GPT-4 before its official release.

GPT-4 exhibits human-level performance on various professional and academic benchmarks. It can accept both text and images as input, making it capable of generating text outputs based on inputs consisting of both text and images. It also performs well in languages other than English, including low-resource languages such as Latvian, Welsh, and Swahili.

OpenAI has made many changes to GPT-4 to make it safer than GPT-3.5 and has been working to mitigate risks. However, GPT-4 still has limitations such as hallucinating facts, making reasoning errors, and not knowing about events after September 2021.

Users who have tried GPT-4 have reported mixed experiences. Some praised its reliability, creativity, and steerability, while others criticized its errors, biases, and security issues. Many users also expressed ethical concerns about the potential misuse of GPT-4 for generating harmful or misleading content.

GPT-4 is a state-of-the-art multimodal AI model that can generate text, images, and even video based on text and image inputs. It is an improvement over GPT-3.5 in terms of reliability, creativity, steerability, and safety. It also supports 26 languages, including five Indian ones.

GPT-4 outperforms other AI models on various benchmarks, such as simulated exams designed for humans. It can also handle complex tasks such as generating code from sketches of websites. However, it still has some limitations such as hallucinating facts, making reasoning errors, and not knowing about events after September 2021

GPT-4 performs very well on human exams, such as simulated bar exams, SAT reading exams, and SAT math exams. It can score in the top 10% of test takers on these exams, while GPT-3.5 scored around the bottom 10%12. GPT-4 can also handle complex problems such as analyzing tax code and generating code from sketches.

However, GPT-4 is not perfect and may still make errors or fail at some exams. For example, it scored only 2 on the AP English Language and Composition exam. It also does not know about events after September 2021, which can affect its accuracy.

GPT-4 is a large multimodal model that can accept both text and image inputs, and generate text outputs. It is an improvement over GPT-3.5 in terms of reliability, creativity, steerability, and safety12. It also supports 26 languages, including five Indian ones.

GPT-4 is based on deep learning technology that uses artificial neural networks to write like a human. It has been trained on more data and has more weights in its model file than GPT-3.512. However, OpenAI has not released details about its size, how it was trained, nor what data went into the process.

Some of the new features of GPT-4 include:

  • Passing a simulated bar exam with a score around the top 10% of test takers; in contrast, GPT-3.5’s score was around the bottom 10%2.
  • Performing well on various other exams, such as SAT reading exam (93rd percentile), SAT math exam (89th percentile), and AP English Language and Composition exam (14th to 44th percentile)2.
  • Generating code from sketches of websites.
  • Analyzing tax code and returning the standard deduction for a couple with specific financial circumstances.
  • Generating images as well as text from the same chat interface.

GPT-4 has been designed with safety as a priority, according to OpenAI12. It has been aligned using lessons from adversarial testing and feedback from ChatGPT users12. It has also been trained to refuse to go outside of guardrails, such as generating harmful or misleading content.

Some of the methods that GPT-4 uses to ensure factuality and safety are:

  • Checking facts against multiple sources before generating text.
  • Using a confidence score to indicate how reliable its output is.
  • Providing citations for factual statements when possible.
  • Avoiding sensitive topics or personal information unless explicitly requested by the user.
  • Asking for clarification or feedback when unsure about the user’s intent or preference.
  • However, GPT-4 is not perfect and may still make errors or fail at some tasks. For example, it does not know about events after September 2021, which can affect its accuracy.

GPT-4 has a multimodal capability that enables it to process both text and image inputs, and generate text outputs based on them123. This means GPT-4 can analyze the contents of an image and connect that information with a written question or instruction.

Some of the tasks that GPT-4 can perform with its image processing capability are:

  • Explaining a meme or a visual joke.
  • Breaking down infographics or graphs step by step.
  • Summarizing scientific graphs or explaining individual aspects of them.
  • Translating and solving exam questions based on images.
  • Identifying what is wrong or humorous in a given image.
  • However, GPT-4 cannot generate images as output, unlike other models such as DALL-E, Midjourney, or Stable Diffusion.