数值分析(php兑现)一:Lagrange插值
数值分析(php实现)一:Lagrange插值
在学数值分析,试着用php实现下,有兴趣的朋友可以粘下来试试
Lagrange插值就是给出n个已知的点,用多项式函数拟合,求出拟合的函数,进而估算未知点函数值的一种插值过程
插值函数是f(x) = xigma(求和) lk*yk
本类实现了插值后显示函数图像的功能
<?php /* * Lagrange插值 * @wangbin * */class Lagrange{ private $dot = array(); public function __construct($array){ $this->dot = $array; } /* * 计算lk * */ private function get_lk($x,$k){ $num = count($this->dot['x']); $omiga_xk = 1; $omiga_x = 1; for($i = 0;$i dot['x'][$k]-$this->dot['x'][$i]); $omiga_x *= ($x - $this->dot['x'][$i]); } } $lk = $omiga_x/$omiga_xk; return $lk; } public function get_y($x){ $num = count($this->dot['x']); $L = 0; for($k = 0;$k get_lk($x,$k); $L += ($this->dot['y'][$k]*$lk); } return $L; } public function draw(){ $img = imagecreate(500,500); imagecolorallocate($img,255,255,2); $num = count($this->dot['x']); $max = 0; for($i = 0;$i dot['x'][$i] ? $this->dot['x'][$i]:$max; $r = 7;//点的半径 $step = 0.1;//步长 for($i = 0;$i dot['x'][$i],$this->dot['y'][$i],$r,$r,1); } for($i = $this->dot['x'][0]-10;$i get_y($current_x); $next_x = $i + $step; $next_y = $this->get_y($next_x); imageline($img,$current_x,$current_y,$next_x,$next_y,1); } header("Content-type: image/png"); imagepng($img); imagedestroy($img); }}$x = new Lagrange(array('x'=>array(10,30,100,120,220),'y'=>array(20,40,240,220,340)));$x->draw();?>


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Microsoft has launched build 25158 in the Windows 11 Development Channel and Windows Server 2022 Preview. For the former, this build includes a host of new features, including different search styles, notification badges in widgets, CD ripping in the media player, and more. Meanwhile, as usual, Windows Server 2022 doesn't even have an update log. Another feature briefly mentioned in Microsoft's announcement blog post is DNSoverTLS (DoT), a network enhancement now available to Insiders. If you are wondering what DoT is, it is DNSoverHT

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

DOT files are document template files in WORD. Read-only means that the system only reads the above data when it is running, and does not rewrite or change it. It is an attribute of the file. As long as the read-only file is not needed or used, it can be deleted.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Watch4pro and gt each have different features and applicable scenarios. If you focus on comprehensive functions, high performance and stylish appearance, and are willing to bear a higher price, then Watch 4 Pro may be more suitable. If you don’t have high functional requirements and pay more attention to battery life and reasonable price, then the GT series may be more suitable. The final choice should be decided based on personal needs, budget and preferences. It is recommended to carefully consider your own needs before purchasing and refer to the reviews and comparisons of various products to make a more informed choice.

How to Optimize iPad Battery Life with iPadOS 17.4 Extending battery life is key to the mobile device experience, and the iPad is a good example. If you feel like your iPad's battery is draining too quickly, don't worry, there are a number of tricks and tweaks in iPadOS 17.4 that can significantly extend the run time of your device. The goal of this in-depth guide is not just to provide information, but to change the way you use your iPad, enhance your overall battery management, and ensure you can rely on your device for longer without having to charge it. By adopting the practices outlined here, you take a step toward more efficient and mindful use of technology that is tailored to your individual needs and usage patterns. Identify major energy consumers
