条件积数学 [英] conditional Product mathematica

查看:170
本文介绍了条件积数学的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Mathematica中复制Lagrange插值多项式.可以在此处看到有关它们的说明的Wiki.这是我的代码(对不起,我不知道如何在其中放置mathematica代码,所以我有图像): 我的问题是我需要有条件的产品.如果j = m,我只想跳过该产品并评估下一个产品.这就是为什么我将错误的评估结果设为1.有何建议?

I am trying to replicate Lagrange Interpolating Polynomials in Mathematica. The wiki for an explanattion of them can be seen here. This is my code (sorry I don't know how to place mathematica code in SO so I have an image): My problem is that I want a conditional product. if j = m I just want to skip over that product and evaluate the next one. That's why I put the false evaluation as 1. Any suggestions?

推荐答案

所有内置函数均以大写字母开头.因此,条件是If[...]而不是if[...].修复此问题,一切正常!

All built-in functions start with a capital letter. So the conditional is If[...] not if[...]. Fix that and everything works fine!

With[{k = 5}, Sum[Product[
  If[j != m, (x - x[m])/(x[j] - x[m]), 1], {m, 0, k}], {j, 0, k}]]

这篇关于条件积数学的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆